Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string forename, surname;
- forename = "James";
- surname = "Shrimpton";
- //Allows you to format a string in a convenient way
- Console.WriteLine("FORENAME:{0} SURNAME:{1}", forename, surname);
- //Outputs the length of a string
- Console.WriteLine(forename.Length);
- //Outputs the characters in the 5th position (index from 0)
- Console.WriteLine(forename[4]);
- //The most Pythonic way to reverse a string
- string reverse = string.Join("",surname.ToCharArray().Reverse().ToArray());
- Console.WriteLine(reverse);
- //Converts a string to upper and lower case
- Console.WriteLine(reverse.ToUpper());
- Console.WriteLine(reverse.ToLower());
- //Single line way of emulating 'String.Title()'
- reverse = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(reverse.ToLower());
- Console.WriteLine(reverse);
- Console.ReadLine();
Advertisement
Add Comment
Please, Sign In to add comment