Input Problems and C# (CSharp) Tutorials
Hi, there. I seen to have problems when I am trying to read the input from the keyboard.
What happens if that I am trying to define an array to a char and I had declared a variabble called "YourName". I ttried to use [] but didn't work for char, and I tried to add the number to the array (for example: [16] but didn't work.
I'd tried one of three things
char YourName[16]; // but this didn't work
char[] YourName[16]; // this didn't work either.
char YourName = new char[16]; // this didn't work either.
Yet...the error also told me that it can't convert char[] into char.
YourName = Char.Parse(Console.ReadLine());
However, I don't seem to have problems with:
Console.Write(("Hello ", YourName.ToString());
--------------------------------------------------------------
So, here's the code to explain a little bit better.
Code:
Using System;
class MainClass
{
public static void Main(string[] args)
{
char YourName[16];
Console.Write(What is your name? (Up to 16 characters) ");
YourName = Char.Parse(Console.ReadLine());
Console.Write("Hello ", YourName.ToString());
}
}
-------------------------------------------------------------------
And, I am looking for a better tutorial that can show me examples along with the explaination. I had read the tutorial in Learn-C-Sharp.com but didn't help. The author should supposed to explain a little bit better about how I can use char with arrays and how can I be able to input into the screen, which means, by reading input from the keyboard, then to input it into a screen. It's true, however, char can hold only 1 character, which is 2 bytes. So, any good tutorials out there?