Web hosting support - CHAPTER 3 74 C# LANGUAGE FUNDAMENTALS Figure
CHAPTER 3 74 C# LANGUAGE FUNDAMENTALS Figure 3-5. Basic I/O using System.Console Figure 3-6. Multiple string literal placeholders // Make use of the Console class to perform basic I/O. static void Main(string[] args) { // Echo some stats. Console.Write(”Enter your name: “); string s = Console.ReadLine(); Console.WriteLine(”Hello, {0} “, s); Console.Write(”Enter your age: “); s = Console.ReadLine(); Console.WriteLine(”You are {0} years old”, s); } Formatting Console Output During these first few chapters, you have seen numerous occurrences of the tokens {0}, {1}, and the like embedded within a string literal. .NET introduces a new style of string formatting, slightly reminiscent of the C printf() function, but without the cryptic %d, %s, or %c flags. A simple example follows (see the output in Figure 3-6): static void Main(string[] args) { … int theInt = 90; double theDouble = 9.99; bool theBool = true; // The ‘n’ token in a string literal inserts a newline. Console.WriteLine(”Int is: {0}nDouble is: {1}nBool is: {2}”, theInt, theDouble, theBool); }
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.