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!

Bubble Sort

Sample source code for implementing bubble sort in C# with an accompanying video explaining how to do it yourself.

C# Lesson 12

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

C# Project 1

Test out your knowledge on basic C# programming with a challenging project doing conversions. Covers lessons 1-6 from the beginner series.

C# Lesson 9

Lesson 9 in our series about learning C# teaches you how to make Strings do your bidding.

Comments

Log in or sign up to leave a comment.