- In C#, you can use strings as array of characters, However, more common practice is to use the string keyword to declare a string variable. The string keyword is an alias for the System.String class.
Creating a String Object:
- By assigning a string literal to a String variable
- By using a String class constructor
- By using the string concatenation operator (+)
- By retrieving a property or calling a method that returns a string
- By calling a formatting method to convert a value or an object to its string representation
Example:
Comparing Strings:
String Contains String:
Getting a Substring:
Joining Strings:
C# .Net Parser Method:
- With parse methods, like int.Parse, we convert strings into low-level types (like ints). We call Parse, TryParse and Convert.ToInt32. For times, we can use DateTime.Parse.
Example:
Output generated using parse method in C# .Net :
No comments:
Post a Comment