Monday, May 4, 2020

C# Tutorial: 01 - C# Basics & Syntax

Tutorial 01: Basics

Welcome to C# Programming Tutorials
In these series of tutorials, we will explore C# and will build a desktop Application.
Before proceeding to application, we will discuss some basics and features of C#.
C# follows Object Oriented Programming paradigm.
In Object-Oriented Programming, various objects interact with each other using actions thereby forming a program. These actions are referred as methods.
It is very easy to learn and if you have some basic knowledge of C/C++ or Java, you can easily understand it.

Following are some features of C#
  • Object Oriented Programming
  • Modern Programming Language
  • Type-Safe
  • Interoperability
  • Scalable and Update able
  • Structured Programming Language
  • Rich Library
  • Component Oriented
Setup and Installation
First download and install Visual Studio from here
Creating a Hello World Program
After installation start Visual Studio from start menu and you will see following screen

Now go to File > New > Project and Click and you will see following screen

Select Console Application and Type Project name in Name field and hit Enter.
Location field explains in which directory of your system, your project will reside.
After creating you will see following screen


Now We'll explain things which are used above.
using
The purpose of using keyword is to include namespaces in program and there can be many namespaces in a program.
namespace
Namespace in C# can be considered as a container, Their purpose organization of the classes and methods.
class
class keyword is used for defining class(s)
Then there is main method it is starting point of execution or it is point from execution starts and curly braces define block of code.
Now add following two lines in block of main method as shown in picture below.
Console.Write("Hello World");
Console.ReadKey();

Console is class which is used for communicating with OS and Write is used to display output on screen.
To execute code Press F5 from keyboard or go to Debug > Start
And you will see output Hello World in console window.


No comments:

Post a Comment