Skip to content

a simple program sorts lowercase alphabet to uppercase, printing each letter in one line using c# methods

Notifications You must be signed in to change notification settings

Powerbliz00/Alphabet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Uppercase Alphabet

This simple C# program demonstrates how to convert lowercase letters to uppercase using the ToUpper() method.

Code Explanation

The code iterates through the lowercase alphabet and converts each letter to uppercase using the ToUpper() method. It then prints the uppercase letters to the console.

using System;

public class Program
{
   // C# Main method - The program start here
    static void Main(string[] args)
    {
        string alphabet = "abcdefghijklmnopqrstuvwxyz";
        // Iteration in each letter in the alphabet string
        foreach (char letter in alphabet){
            // definition of new variable 'letterCapitalCase' for converting char type into string output
            string letterCapitalCase = letter.ToString().ToUpper(); 
            // Output method
            Console.WriteLine(letterCapitalCase);
        }
    }
}

Running the Program

Windows

  1. Install .NET SDK: If you don't have it already, download and install the .NET SDK from https://dotnet.microsoft.com/download.
  2. Compile the code: Open a command prompt and navigate to the directory containing the C# file (Program.cs). Run the following command to compile the code:
    dotnet build
  3. Run the program: Execute the following command to run the compiled program:
    dotnet run

Linux

  1. Install .NET SDK: Install the .NET SDK using your distribution's package manager. For example, on Ubuntu:
    sudo apt update
    sudo apt install dotnet-sdk-6.0
  2. Compile the code: Open a terminal and navigate to the directory containing the C# file (Program.cs). Run the following command to compile the code:
    dotnet build
  3. Run the program: Execute the following command to run the compiled program:
    dotnet run

Output

The program will output the uppercase alphabet to the console, one letter per line:

A
B
C
...
Z

This repository serves as a basic example of string manipulation in C# and demonstrates the use of the ToUpper() method and the need of Type conversion from char type from string type, using ToString() method.

About

a simple program sorts lowercase alphabet to uppercase, printing each letter in one line using c# methods

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages