First of all, Console.ReadKey()
is not the answer.
I need to be able to erase the first character I write.
Basically, what I'm trying to do is an application that measures your typing speed. It works perfectly, but I'm trying to work out the aesthetics.
What I was doing at first was calling Console.ReadKey()
, then calling this function that starts a Timer (well, I realized 30 minutes after I wrote the application that there happens to be a Stopwatch class ._.), and I would store the string that the user inputs with Console.ReadLine()
, then stop this Timer.
static Word[] getWords()
{
Word[] words;
int c = Console.ReadKey().KeyChar;
Timing.start();
string str = (c.ToString() + Console.ReadLine()).ToLower();
charCount = str.Length;
words = Word.process(str);
Timing.stop();
return words;
}
charCount
is a static int, and Word
is just a class that wraps a string.
Word.process
is a function that takes a string, omits all the symbols and returns an array of the words that the user types.
Timing
is just a class that wraps the Timer
class.
I think that's all that needs to be explained concerning the code.
What I need to do is call Timing.start()
when the user types a character and he has to be able to erase it.