C Sharp Fundamentals/Hello World
C#
editC# is a general-purpose, type-safe, object-oriented programming language. It was developed around 2000 by Microsoft as part of its .NET initiative.
Comments
editComments are bits of text that are not executed. These lines can be used to leave notes and increase the readability of the program.
- Single-line comments are created with two forward slashes //.
- Multi-line comments start with /* and end with */. They are useful for commenting out large blocks of code.
Example
edit// This is a single-line comment
/* This is a multi-line comment
and continues until the end
of comment symbol is reached */
Console.ReadLine()
editThe Console.ReadLine() method is used to get user input. The user input can be stored in a variable. This method can also be used to prompt the user to press enter on the keyboard.
Example
editConsole.WriteLine("Enter your name: ");
name = Console.ReadLine();
.NET Platform
edit.NET is a free, cross-platform, open source developer platform for building many different types of applications.
With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, gaming, and IoT. Whether you’re working in C#, F#, or Visual Basic, your code will run natively on any compatible OS. Different .NET implementations handle the heavy lifting for you.
Console.WriteLine()
editThe Console.WriteLine() method is used to print text to the console. It can also be used to print other data types and values stored in variables.
Example
editConsole.WriteLine("Hello, world!");
// Prints: Hello, world!
Practice
edit