TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
357
120.8k
Retrieving data from a property
Jul 6 2012 10:41 AM
Hi
Given the following code I came across:-
ConsoleKeyInfo cki;
cki = Console.ReadKey();
Console.WriteLine("Key pressed: {0}\n", cki.Key);
if (cki.Key == ConsoleKey.X)
break;
My question is, how is the Key property holding the required data without even being set?
The only thing I can see happening is that the instance variable cki is storing the return value captured from the ReadKey method.
Id usually expect to see the something like:-
ConsoleKeyInfo cki = new ConsoleKeyInfo();
cki.Key = Console.ReadKey();
Console.WriteLine("Key pressed: {0}\n", cki.Key);
Regards
Steven
Reply
Answers (
4
)
Generating Payslip
how to display xml returned image into windows phone app