using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string text = "This is a random text";
string text2 = "This is a random text !!!";
Console.WriteLine("Is empty: " + String.IsNullOrEmpty(text)); //is it empty?
Console.WriteLine("Is white space: " + String.IsNullOrWhiteSpace(text)); //dose it have white spaces?
Console.WriteLine("String length: " + text.Length); // dah text length
Console.WriteLine("Index of random: " + text.IndexOf("random")); //were is random in the text string
Console.WriteLine("Substring : " + text.Substring(2, 6));
Console.WriteLine("Strings equals : " + text.Equals(text2)); //check if eqaul
Console.WriteLine("Starts with \"This is\": " + text.StartsWith("This is"));
Console.WriteLine("Ends with \"!!!\": " + text.EndsWith("!!!"));
text = text.Trim(); //remove the white space at start and and of the string (Trim/TrimEnd/TrimStart)
text = text.Replace("random", "exact");
Console.WriteLine(text);
text = text.Remove(0, 5); //remove chars from 0 to 5
Console.WriteLine(text);
string[] names = new string[3] { "Vlad", "Dan", "Boss" }; //this is how you define an array of strings
Console.WriteLine("Name List: " + String.Join(", ", names));
Console.ReadLine();
}
}
}
Comments