Welcome back.
In this video I want to show you another data type that we haven't covered yet but is quite important.
That is the chart data type.
The chart data type can contain one character and one correct character only, not more than that.
So I can go ahead and call this one my favorite character, for example.
And if I want to assign a character to a char data type, I need to use the single quotes and I need
to assign a value so it cannot be empty.
So here I can, for example, assign zero or A or B, or any other letter slash character on your keyboard
is part of the characters that can be displayed.
But there are other characters in here as well, like smileys, for example, or Chinese characters.
So they are basically any characters that are inside of the UTF 16 table.
So what is this UTF 16 table?
It's basically here.
This Unicode transformation format is this UTF 16.
It's a character encoding capable of encoding all 1,112,064 valid code points of Unicode.
Okay.
So it is changing.
I think they are constantly evolving, but these are the characters in there.
So it's very difficult to read.
But once you zoom in you see a bunch of Chinese characters, a few Arabic and all kinds of other languages
in here that are inside of this UTF 16 that you can now display using the code.
Basically the UTF 16 code, which is just 16 bits, which means 16 ones and zeros that then convert
into one of those characters based off based on this table that we have here.
Okay.
So if you go back and you go to UTF 16, you can check out Wikipedia for that.
Or you can also check out other sources.
But basically what it says is it converts a binary UTF 16 code into a character.
So the character dollar sign, quite an important character I would say is comprised of this binary
number here.
So zero four zeros another (400) 010-0100.
So this is converting into hex 24.
And this will then give us the dollar sign okay.
So you don't need to memorize any of that.
I just wanted to give you a bit of a background information on that as well, so that you understand
that you can have all kinds of characters in here.
So let's say you wanted to have a smiley in there, this Unicode character, I tried it for some reason.
It doesn't want to work, but this one does work.
So if I copy this smiley and I put it into my code here, like so, now I have this as a single UTF
16 character, so I can write it out using Console.WriteLine.
And I'm going to say my favorite character.
And let's print out the smiley to our console.
And we should see our smiley up here.
You see very very small.
But yeah it's there.
So this is the char data type.
Very simple data type yet quite important because sometimes you just want to have one character instead
of a string of characters which is string.
So if you want to have a bunch of different characters combined in a text, in a word, in a sentence,
then you use the string keyword.
And if you just want to have one character and you want to save storage, then the char data type is
quite important.
So that's it for this video.
See you in the next one.