String Basics
Strings and Chars
A
charis a single 'character'.A
stringis essentially an array ofchar.Both of the following data structures practically have the same properties, and the two
WriteLine()will printb.
char[] chars = { 'a', 'b', 'c', };
string str = "abc";
Console.WriteLine(chars[1]);
Console.WriteLine(str[1]);Properties of Strings
Length
string str = "This is a string";
int len = str.Length;
// len will be 16Null Check
Often a string needs to be checked for
nullorEmpty.Following methods facilitates this.
Last updated