Console applications in C# have exactly the same purpose as regular console applications: to accommodate a command band interface with the user. Their main advantage is the fact that they are easily controllable by other software. For instance, a coder can actualize abundant animate applications that accept the aforementioned functionality as a Windows GUI appliance and a arrangement ascendancy affairs that runs these applications. The accessories offered by the applications are attainable both to the user and to the ascendancy program. The facilities offered by the applications are accessible both to the user and to the control program. Console applications have three main input streams: standard in, standard out and standard error. These streams are initialized by the operating system, generally. However, if an appliance runs a animate appliance as a sub-process, it can trap these streams and control them. What the reader should keep in mind about these streams, for now, is that they are buffered.
//Declare a String variable. Name it userName
string userName;
Console.Write("Console Asks - Please Enter your Name: ");
//Place the user input into the variable userName with
//Console.ReadLine()
userName = Console.ReadLine();
//Skip a line for nicer formatting
Console.WriteLine("");
//On the next line, display the input.
//{0} is where the variable value will go. It
//is followed by a comma and variable name userName
Console.WriteLine("Hello {0}!", userName);
Console.WriteLine("Press Enter to Continue");
//The Console.Readline will pause the program until you
//press [ENTER]. Then it will exit.
Console.ReadLine();
} //end main
} //end class
} //end namespace
0 comments:
Post a Comment