c sharp tutorial 2What is C #?

C# is a programming language developed by Microsoft. It is a fully object-oriented programming language like Java, and it’s the only component presented by -oriented language. C# is derived from C and C++ languages.  It is suitable for developing web-based applications and supports the .NET framework, Microsoft’s development platform.

Want to learn C#? Take a course at Udemy.com.

C# Features

Though C# is the successor of languages like C and C++ with several similarities in comparison, it contains several unique features:

What is .NET Framework?

Any language can access the .NET framework as well as communicate with each other using .NET libraries. In addition, it is a component-based model in which a program is broken into numerous individual components where each one offers a particular service. This mechanism is called Microsoft Intermediate Language (MSIL). The most striking feature of .NET framework is the compiler inter-operability by compiling code into an IL that is compatible with other IL modules. Microsoft .NET software provides building, deploying and running web services and other console applications. It consists of three different technologies:

Common Language Runtime (CLR) provides runtime environments for languages including C#.

The CLR provides a number of services that include:

Hello World with C#

A simple C# program has following parts:

Learn how to work with the C# language at Udemy.com.

Example

using System;

namespaceHelloWorld

{

class Hello

{

static void Main()

{

/* it is Hello World in C# */

Console.WriteLine(“Hello World”);

 

}

}

}

Output

Hello World

Points to Note:

Compiling and Running The C# Program:

From Visual Studio

From Command line:

Example of Command Line Arguments

using System;

namespaceHelloCommandLine

{

class Hello

{

static void Main(string[] args)

{

/* it is Hello World in using Command Line Argument */

 

Console.Write(“Welcome to  Command Line “);

Console.WriteLine(“”+arg[0]);

Console.WriteLine(” “+args[1]);

 

}

}

}

Notice in this Main method declaration

public static void main(string args[])

Main method is enclosed with the parameter “args”. The parameter is the array of strings also known as “String objects“. Any arguments given in the command line at the time of execution is passed to “args” as its elements. These elements are then accessed by using subscript args[0], args[1] and so on.

If you provide three arguments at the time of execution for instance

thisàargs[0]

isàargs[1]

commandlineàargs[2]

argumentàargs[3]

The only difference between WriteLine() and Write() method is that the latter does not create a line break and therefore the next output will be printed on the same line.

Applications of C#

 

Framework Base Classes

 

.NET supplies a library of base classes that help you implement web applications quickly. You can use them by instantiating the program and invoking their methods. The namespace named System includes a lot of functionality.

 

User and Program Interfaces

 

.NET provides many tools for managing user applications

 

Tools Required for C#

One thing to note is that .NET framework only works for Windows environment and you cannot run the C# program without .NET framework. Though Mono an open source platform of .NET framework includes C# compiler, it has been developed so that it can run C# program on cross platforms, including Mac OS.

Get to know more about the C# language at Udemy.com.

Top courses in C#

How to Program Voxel Worlds Like Minecraft with C# in Unity
Penny de Byl, Penny @Holistic3D.com
4.7 (1,235)
Learn C# for Beginners Crash Course
Tim Buchalka, Jean-Paul Roberts, Tim Buchalka's Learn Programming Academy
4.7 (536)
Design Patterns in C# Made Simple
Zoran Horvat
4.7 (49)
Highest Rated
Complete C# Unity Game Developer 2D
Ben Tristem, GameDev.tv Team, Rick Davidson
4.6 (77,145)
Bestseller
Complete C# Unity Game Developer 3D
Ben Tristem, Rick Davidson, GameDev.tv Team
4.6 (21,241)
Bestseller

More C# Courses

C# students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo