C# tutorial- Basic Syntax

C# Basic Syntax

-Using System; is a statement to indicate that you are using a namespace called System. Basically this namespace contains a class (Console) with methods needed to print the values on the screen and read the values from the keyboard.

-Using System.Collections.Generic is a statement to use Generic namespace that contains interfaces and classes to allow the user to create strong types collections.

-Using System.Linq; is a statement to use Linq namespace that contains interfaces and classes that support query.

-Using System.Text; is a statement to use Text namespace that contains classes that represent ASCII, Unicode, UTF-7, and UTF-8 character encodings, convert bytes to characters and vice versa, and manipulate and format string objects.

For now the last three statements are not important, but they will be used in the next sections of this tutorial.

-For the console application, the program will start from Main method of class Program that is contained in a namespace (e.g. Ctest).

-Console.WriteLine(“Hello World!”); is used to print the text “Hello World” on the screen.

-Console.ReadLine(); is used to read a value from the keyboard.

Comments in C# programming language

Like other languages, C# comments are used to explain the code written and to disable the code that we do not want to be executed. There are two types of comments:

-// used to make comments for a single line

-/*      */ used to make comments for multiple lines


vishvesh comment



chinmai comment


Thanks for your details and explanations..I want more information from your side..please include some valuable ideas..I Am working in <a href="http://www.jklaptopcare.com">used laptops sales in chennai</a>should you need for any other clarification please call in this number.044-421 27512.

MohitKumar comment


check this also for c# interview questions http://skillgun.com/csharp/interview-questions-and-answers


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.