As we know that now a days C# plays a major role in most of the Web technologies to write the server side code, Ex: ASP.NET, ASP.NET MVC etc., Lets see Language Basics of C# in this chapter.
Hello friends, we have seen creating a simple Hello program
in the previous chapter
. Lets see some more language basics of C# in this chapter.
Language Basics of C#
We have already seen
comments that are being used in C# in the previous chapter.
What is a source code?
-Source code is a set of files with .cs as extension. Ex: Program.cs
What is Assembly?
-Assembly is a Packaging and Deployment unit of .NET such as
What is a Library?
-Library is a file without an entry point which is called(referenced) by an
application or other
library. These files are extended with .dll.
.NET Framework is a set of libraries.
Compiler compiles the source code into an Assembly. '
' is the name of C#
compiler. We can use IDE
(Integrated Development Environment) such as Visual Studio
or calling it from the command line manually.
We have already seen compiling with Visual Studio in the before chapter and if we want to compile it using command line,
- Save a program with
.cs extension such as
- Now go to the Command and invoke csc which is located at,
RootFolder(Windows Directory)\Microsoft .NET\Framework\
i.e, csc Program.cs
- This will create an application named Program.exe.
- Now, do the following to create a library.
csc /target:library Program.cs
Lets have a simple program like below to explain Identifiers and Keywords,
static void Main()
int a = 15 + 25;
In the above code, we are performing addition operation.
Identifiers(names) are the being chosen by programmer for his requirements such as
, are the Identifiers in the above program.
- Identifier must be a complete word, which is made up of Unicode characters that are started with a
- In C#, Identifiers are case-sensitive.
- Generally, local variables, parameters and private fields should be in Camel case(Ex: myVariable) and remaining should be in Pascal case(Ex: MyMethod).
Keywords:Keywords are the reserved names of the compiler which we can't use as Identifiers.
Using, class, static, void, int are the Keywords in the above program.
Below are the list of Keywords used in C#
There are some keywords which might be used as Identifiers. Those are called as Contextual Keywords.
Below are the Contextual keywords which are also used as Identifiers
In this article, we have seen basics of C# language in which Keywords, Identifiers and Compilation. Hope you understand them clearly. If you have any doubts on this topic, please feel free to ask in the below comments.
Thanks for reading,