System.String—Find string length


Jump to: navigation, search
C# Code Snippets

C# Source Code Bank

See also …
edit

This C# code snippet gets the length of a string.

string motto = 
   "Drive thy business or it will drive thee.";	
Console.WriteLine ("motto is " 
   + motto.Length 
   + " characters long.");

If the string is uninitialized or null, a NullReferenceException will be generated.

If the string is Empty or equals "", the Length will be zero.



Personal tools