C# Lesson 8

Characters, the data type that's just a little less useful than a string.

The while statement is simple loop. As long as the condition inside the while() evaluates to true, the section of code will keep repeating itself.
Afterwards you can continue to the next lesson!
Or go back and review the previous lesson.
We also have the source code on GitHub.


using System;

namespace Lesson8
{
    class Characters
    {
        static void Main(string[] args)
        {
            // b
            // 2
            // !
            // Ñ

            Console.OutputEncoding = System.Text.Encoding.UTF8;// Add this last

            char myFirstChar = 'Ñ';
            Console.WriteLine("Char: " + myFirstChar + " | Int: " + Convert.ToInt32(myFirstChar));

            for (int x = 1; x <= 209; x++)
            {
                char numberToChar = Convert.ToChar(x);
                Console.WriteLine($"count {x} : {numberToChar}"); // Show ascii/unicode table after this
            }

        }
    }
}


/*
* TASK:
*   Make a for loop that starts at 97 and goes to 122 (includes 122).
*   Convert the integer you use for the for loop into a char and print it. 
*   It will print a lowercase letter.
*   Then print the same letter but in uppercase in the same loop.
*   
*   You can use https://en.wikipedia.org/wiki/List_of_Unicode_characters as a reference.
*/

using System;

namespace Lesson8Task
{
    class CharactersTask
    {
        static void Main(string[] args)
        {
        }
    }
}

Recommended posts

We have similar articles. Keep reading!

C# Lesson 7

You're familiar with "while" loops in C#, but but it's time to learn about "for" loops. Let's get loopy in the 7th lesson in our series about learning C#.

C# Lesson 12

Lesson 12 in a our series about learning C# teaches you about working with methods.

C# Lesson 5

Run sections of your code only IF you want them to with the "if" statement in the 5th lesson from the series on learning C# for beginners.

C# Lesson 6

Learn about "while" loops, a way to make sections of code repeat, in our 6th lesson in the C# series for beginners.

Comments

Log in or sign up to leave a comment.