sasfvs

Untitled

Jul 3rd, 2017
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string text = "This is a random text";
  14.             string text2 = "This is a random text !!!";
  15.  
  16.             Console.WriteLine("Is empty: " + String.IsNullOrEmpty(text)); //is it empty?
  17.             Console.WriteLine("Is white space: " + String.IsNullOrWhiteSpace(text)); //dose it have white spaces?
  18.             Console.WriteLine("String length: " + text.Length); // dah text length
  19.             Console.WriteLine("Index of random: " + text.IndexOf("random")); //were is random in the text string
  20.             Console.WriteLine("Substring : " + text.Substring(2, 6));
  21.             Console.WriteLine("Strings equals : " + text.Equals(text2)); //check if eqaul
  22.             Console.WriteLine("Starts with \"This is\": " + text.StartsWith("This is"));
  23.             Console.WriteLine("Ends with \"!!!\": " + text.EndsWith("!!!"));
  24.             text = text.Trim(); //remove the white space at start and and of the string (Trim/TrimEnd/TrimStart)
  25.             text = text.Replace("random", "exact");
  26.             Console.WriteLine(text);
  27.             text = text.Remove(0, 5); //remove chars from 0 to 5
  28.             Console.WriteLine(text);
  29.             string[] names = new string[3] { "Vlad", "Dan", "Boss" }; //this is how you define an array of strings
  30.             Console.WriteLine("Name List: " + String.Join(", ", names));
  31.             Console.ReadLine();
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment