String and StringBuilder :
String
A string is a sequential collection of Unicode characters that is used to represent text. A String Object is a sequential collection of system . Char object that represent a string. The Value of string object is the content of the sequential collection, and that value is immutable . The maximum size of a String Object in memory is 2GB,or about 1 billion characters.
Properties:
There are two types of property in this
Length:
In this we will specify the length of the character of given String .
Chars:
In this we will specify the position of the char.
Methods
Compare (String ,String ) :
In this methods compare String object and returns an integer value
Concat (String ,String) :
: In this we will Concatenates two specified instances of String.
Contains :
Return a value indicates whether the specified String object occurs within this String .
Copy :
Creates a new instance of String with the same value as a Specified String.
IndexOf(string)
Report the zero-based index of the first occurrence of the specified String in this instance .
LastindexOf(String)
Reports the zero based index position of the last occurrence of a specified String within this instance.Remove (In32)
Returns a new string in which all the characters in the current instance ,begging at the specified position and continuing through the last position ,have been deleted.
ToLower () :
Returns a copy of this string converted to lowercase .
ToUpper() :
Returns a copy of this string converted to uppercase .
Trim () :
Remove all leading and trailing white -spaces characters from the current String object.
A simple Program using String Methods :
StrMethods.cs: class StrMethods { static void Main() { string[] myStrings={"I" ,"am", "scanf", "hello"}; string myStrings=String.Join(".",myString); string myString 10 =myString.Insert(6,"A"); Console.WriteLine("myString.Insert(6,\"A,\")="+myString 10); string myString11=myString10.Remove(14,7); Console.WriteLine("myString10.Remove(14,7)=" +myString11) string myString12=myString11.Replace(',','?'); Console.WriteLine("myString11. Replace(',','?')=" +myString12) string myString 13 =myString12. Replace ("I am scanf","hello"); Console.WriteLine("myString11. Replace(\"I am scanf",\"hello")=" +myString13) Console.ReadLine(); } }