Strings manipulation Learn programming C#

Lesson:

Arrays, Structures and Strings


Exercise:

Strings manipulation


Objetive:

Create a C# program that asks the user for a string and:

- Replace all lowercase A by uppercase A, except if they are preceded with a space
- Display the initials (first letter and those after a space)
- Display odd letters uppercase and even letter lowercase

The program must display all generated strings.


Code:

using System;
class exercise89
{
    static void Main(string[] args)
    {
        Console.Write("Tell a string: ");
        string Entry = Console.ReadLine();
        string result;
        result = Entry.Replace("a", "A");
        Console.WriteLine(result);
        Console.WriteLine(UppercaseFirst(Entry));

    }
    public static string UppercaseFirst(string s)
    {
        return char.ToUpper(s[0]) + s.Substring(1);
    }
}

Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.