Compare the Read Line and Read Key and Explain The Features of these.
Finally Give Few Examples to complete your Explanation.
Best Wishes
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 20, 2014, 6:41 AM EDT
http://www.blackwasp.co.uk/ConsoleInput.aspx
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 20, 2014, 5:03 AM EDT
Read() :accept the string value and return the string value.
Readline() :Accept the string and return Integer
ReadKey() : Accept the character and return Character
Declaration In Application:
Ranjit PowarRank #553 · 4.4K reputationPosted Apr 20, 2014, 10:57 AM EDT
ReadKey() method takes a single character and return values of ConsoleKeyInfo structure.
This struct describes console key that was pressed and it also gives the state of modifier keys like SHIFT,CTRL,ALT.
class Program
{
static void Main(string[] args)
{
string s;
s= Console.ReadLine();
Console.WriteLine(s);
ConsoleKeyInfo k = Console.ReadKey();
Console.WriteLine(k.KeyChar );
Console.WriteLine(k.Key);
Console.WriteLine(k.Modifiers );
Console.ReadKey();
}
}
Joe WilsonRank #631 · 3.8K reputationPosted May 10, 2014, 5:18 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted May 10, 2014, 5:19 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted May 24, 2014, 9:03 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 26, 2014, 3:29 AM EDT
You are therefore prevented from assigning a different value to it at a later stage.
Check the example in MSDN:
http://msdn.microsoft.com/en-us/library/acdd6hb7.aspx
Bhabani PrasadRank #8,369 · 223 reputationPosted May 26, 2014, 4:16 AM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Jun 1, 2014, 10:38 PM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Jun 1, 2014, 10:39 PM EDT
Joe WilsonRank #631 · 3.8K reputationPosted Jun 5, 2014, 3:49 AM EDT
Thank you.