using System; class Program { static void Main(string[] args) { string message = "hello world"; string uppercase = message.ToUpper(); string reversed = ReverseString(message); int index = message.IndexOf('o'); string substring = message.Substring(6, 5); Console.WriteLine("Original message: " + message); Console.WriteLine("Uppercase: " + uppercase); Console.WriteLine("Reversed: " + reversed); Console.WriteLine("Index of 'o': " + index); Console.WriteLine("Substring: " + substring); } static string ReverseString(string input) { char[] charArray = input.ToCharArray(); Array.Reverse(charArray); return new string(charArray); } }This example creates a string, manipulates it using string methods, and outputs the results to the console. The following steps are performed:
- Define a string with the value “hello world”.
- Convert the string to uppercase using the
ToUpper()
method and store the result in a new string variable.- Reverse the string using a custom
ReverseString()
method and store the result in a new string variable.- Find the index of the letter ‘o’ in the string using the
IndexOf()
method and store the result in an integer variable.- Extract a substring of the string using the
Substring()
method and store the result in a new string variable.- Output the original string and the manipulated strings to the console using
Console.WriteLine()
.Note that there are many other string methods and operations you can perform, such as replacing text, formatting, and splitting. This example is just one possible multi-step process for working with strings.