Manipulating Strings

By   Posted at  5:25:00 AM  

Home  »  C#  »  Manipulating Strings

     Like an integer characters are also be in the Array The Array of Characters are called as the Strings They are Generally used for representing the Strings in C# String is Also Array and Also a Class .we Know that when Collection of Characters are called as String In C# For Creating an String array You Will use as Follows:-

string s;

here s is a String Variable
Generally there are two types of Strings in C# those are Also Called as immutable and mutable . The Immutable Strings are those are which operates in a Static Manner Means we cant change the Length of a String Means we can only Operate the String Means we can Only Perform Some Functions Like upper case , Length etc.
System NameSpace Contains a String Class Which is immutable in nature Means we can only Perform Some Convertion Functions But we cant modify the String Means We cant alter the Length of String.

Various String Methods those are Reside in String Class are :-
1. ToLower- For Converting a String into small letters or in small cases.
2. ToUpper- For Converting a String into Upper letters or in Upper cases.
3. Trim:- For Removing both left and Right Side Spaces.
4. CompareTo() :- Compares the current String With Another.
5. IndexOf:- For Finding the Position of a Character in a String.
6. Substring:- For Extracting a string from a string.
7. Replace:- For Replacing a Character in the String.
8. compareTo:- For Comparing a String With another.
9. Split :- Split a String into the Number of Characters.
10. Concat:- For Joining Two strings and Making a Single String.
11. TrimStart:- For Removing the Spaces from Start.
12. TrimEnd:- For Removing the Spaces from the End of String.


Mutable Strings

     These are Also Special types of Strings those can be Modified The StringBuilder Class is Called as Mutable String and these are also called as Dynamic Strings For Using StringBuilder Class We have to use System NameSpace along with a class whose name is Text. Means System.Text Class is used for Creating a StringBuilder Class with Various Methods those may applied to a String The Various Methods of StringBuilder Class are :-

1) Append :- Used For Inserting String at the End of Existing String.
2) Insert :- For Inserting a String into the Specific Position.
3) Remove :- For Removing Some Characters from a String.
4) Replace:- For Replacing Specified Characters of a String.
5) Capacity :- This Will Returns the No of Characters that a String May hold.
6) Length: This Will Retrieve us the Total Number of Characters in a String.

Regular Expression

     The Regular Expressions are used for Seraching and then Manipulating a String or a Larger Text or we can say Regular Expressions are:-
1) For Locating a String From Existing String.
2) Modifying the String After Searching.
3) Splitting a String into Many Sub Strings etc.

For Searching Some Characters we have to Specify the Pattern For Matching and For Using Regular Expressions first we have to use System.Text.RgularExpressions Namespace and we have to use Split Function if we wants to divide a String into Many Sub Strings and for Splitting we have to use StringBuilder Class.

Inserting Strings

Encoding Strings

Comparing Strings

Formatting Strings

Finding Substring

Mutable String

String Array

Regular Expressions

StringBuilder Class

About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

Back to top ↑
Connect with Me