Your first Hello World app in C# Sharp. In our tutorial, we will be using the functionSystem.Console.WriteLine
to write lines to the output console. When writing a C# command line application, the same function can also be used to print to the console.
Note: Writing web applications using C# is possible using the ASP.NET framework.
Exercise: Your first Hello World app in C# Sharp
Print a message to the console. The code below prints Hello World to the screen using System.Console.WriteLine go ahead and output other messages other than ‘Hello World’… The more you code the more you know.
This method uses the composite formatting feature of the .NET Framework to convert the value of an object to its text representation and embed that representation in a string. The resulting string is written to the output stream.
The format parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to an object in the parameter list of this method. The formatting process replaces each format item with the text representation of the value of the corresponding object.
The syntax of a format item is {index[,alignment][:formatString]}, which specifies a mandatory index, the optional length and alignment of the formatted text, and an optional string of format specifier characters that govern how the value of the corresponding object is formatted.
The .NET Framework provides extensive formatting support, which is described in greater detail in the following topics.
- For more information about the composite formatting feature supported by methods such as Format, AppendFormat, and some overloads of WriteLine, see Composite Formatting.
- More information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.
- For more information about the date and time format specifiers, see Standard Date and Time Format Strings and Custom Date and Time Format Strings.
- More information about enumeration format specifiers, see Enumeration Format Strings.
- For more information about formatting, see Formatting Types in the .NET Framework.
For more information about the line terminator, see the Remarks section of the WriteLine method that takes no parameters.
Related Videos:
Related Links:
MSDN on Console.WriteLine Method
Introduction to Batch File Viruses