- Dotnet Blogs -

Learn C# Programming Tutorial for Beginners

Hope you are good! You are landed to the page because you are a beginner in the C sharp programming and wanted to learn C# Programming step by step from scratch. Well, you have landed in the right place finally and we have compiled a C# tutorial for beginners carefully after reading out multiple books and reference links. Our C# tutorial is 100 percent result-driven for the beginners that will help you in getting started with C# basic concepts.

C# Introduction and features

If you are a beginner and interested in learning a new language, C sharp is the right choice to start your career. C sharp offers wonderful memory management techniques and solid safety types as compared to other programming languages. The dot net framework in C# has a robust set of class libraries to work with the file systems, security principles, and much more.

C sharp is a highly popular programming language like Java and Microsoft keep updating language features from time to time. With the release of the dot net core framework, C sharp will be in huge demand by the year 2018. This programming language is easy to learn and understand that helps you in designing a variety of software applications quickly. Here are a few highlights that make C sharp widely used programming language –

  • C sharp is a modern object-oriented programming language
  • C# is a component-oriented language that can be understood quickly.
  • This is a structured programming language that helps programmers in writing most efficient software programs.
  • The programming language is compatible with a variety of computer platforms.
  • This is an important part of dot net framework that makes it more popular among .net professionals.

Learn C# - Framework vs. Programming Language vs. IDE

Before starting with C# programming, it is necessary to understand the difference between three popular terms – Framework, Programming Language, and IDE. In most of the cases, all of these terms are used interchangeably by beginners without knowing their actual meaning and significance. Visual Studio is an IDE, .NET is a framework, and C# is a programming language. Learn C# Programming Tutorial for Beginners

The .NET framework has a huge collection of class libraries and reusable components. Further, you need a software application to invoke those components. The software application will be written in programming languages like C sharp or VB .NET etc.

If you are interested in writing any professional application that is really huge in size. Here, you need to automate certain things to speed up the task. This code management and automation techniques are offered by the IDE. This may be difficult to work with all the utilities in beginning, but things will get smoother as soon as you become more familiar with them.

Learn C# Programming Structure

Before we switch to advanced programming concepts, we should study programming structure first. A C# program consists of the following parts – Namespace, comments, class, class methods, statements, expressions and one main method etc.

Read: Microsoft .Net Software Developer Salary in USA

Let us look at the simple program that prints “Hello JanBask” as the final output-

[code lang="php"] using System; namespace HelloJanBaskApplication { class HelloJanBask { static void Main(string[] args) { /* my first program in C# */ Console.WriteLine(“Hello JanBask”); Console.ReadKey(); } } }[/code]

Output – Hello JanBask

This is the right time to discuss on each and every concept of the program in detail –

  • The “using” keyword in the first line is written to include the “System” namespace in the program. In a single program “using” keyword can be utilized more than once.
  • In the second line, “namespace” is used as the declaration. Inside the namespace, we can declare multiple classes together. For the above example, declared class name is – “HelloJanBask”.
  • In the third line, “class” is used as the declaration. Inside “class”, we can declare multiple methods together. For the above example, there is one “Main” method and “WriteLine” and “Readkey” are the sub-methods.
  • The “Main” method is an entry point for C sharp programs. This method explains the behaviour of the class and also decided when it needs to be executed.
  • The comment section /**\ is used to increase overall readability of the program. This is a good programming practice and necessary to practice for all C sharp developers.
  • The “WriteLine” method is used to display the message on the screen and “Readkey” method in the last line is used to control the behaviour of previously used methods.

From the above discussion, you are ready to write a short program in C#. Make sure that you are familiar with the syntax well and it should be used wisely without making multiple errors. Also, it is case-sensitive so C sharp program should be written carefully.

How to compile or execute C# program using IDE and using command prompt?

Visual studio .NET Framework

  • Open the Visual Studio from Program Files.
  • In the Menu bar, there is one File Option. You need to choose “New” option, then click on the sub-option “Project”.
  • Select Windows option on the left side and choose Console Application at the right hand.
  • Give a good name to your project and press OK button to save the project in Solution Explorer.
  • Now you are ready to start coding in the code editor.
  • There is Run option at the top or you can use the F5 key to execute the C# program. A command prompt will appear in front of you with the final output.

Learn C# Programming Tutorial for Beginners

Command-line prompt for program execution

If you are not interested in Visual Studio IDE then there is one other option too i.e. command-line prompt to execute the same C# program.

  • Here, you have to write code to a text editor or simply copy the “Hello JanBask” code to understand the execution process well.
  • The text file should be saved as hello JanBask.cs
  • Now open the command-line prompt and type CSC hello JanBask.cs to compile the program.
  • If compilation is done successfully then it will take you to the next stage helloJanBask.exe executable file.
  • Now type hello JanBask, on execution, it will display the final output on the screen.

Learn C# Basic Syntax

Identifiers – An identifier in C# is used to identify some class, members, functions, etc. Here are some rules to name classes in C# like it should be started with a character only not the digits. We cannot use any special symbol for the class declaration, but underscore (_) can be used if necessary.

Read: What is Microsoft .Net Framework? Complete Architecture Tutorial Guide

Keywords–Keywords are pre-defined in any programming language and they have significant meaning relevant to the code. There are two types of keywords in C sharp – The first category is reserved keywords and the other is contextual keywords. Contextual keywords are normally used in the context of code. Learn C# Programming Tutorial for Beginners Learn C# Programming Tutorial for Beginners

C# Data Types

The data types in C sharp are divided into three major categories – value types, pointer types, and reference types. Value data types are able to accept value directly in the form of characters, integers etc. Here is a complete list of value data types are frequently used by the C sharp programmers.

Learn C# Programming Tutorial for Beginners

Reference Types – These data types don’t contain the actual value but they store reference value to the variables. For example, Reference data types can be used to represent memory location that keeps changing automatically.

Pointer types – These data types are used to store memory address and it has the same capabilities as pointers in C language or C++ language. Here is a quick example how to declare pointers in C sharp. Learn C# Programming Tutorial for Beginners

Type conversion in C sharp

Type conversion or typecasting is a popular programming feature where one data type is converted to another form as per the requirements. Here are two popular categories of type conversion in C sharp –

  • Implicit Type Conversion – These types of conversions are performed by C sharp in a safe manner. For example –Small integers are converted to large integers or base classes are converted to derive classes and vice versa.
  • Explicit type conversion–These conversions are performed with the help of pre-defined functions so it is named as explicit type conversions. One quick example how explicit conversions are performed actually, it is given below –

Learn C# Programming Tutorial for Beginners

Read: Top Dot Net Interview Questions and Answers

C sharp Constants, Variables, Literals and Operators

C# Variables–Variable is a name given to the storage area that can be manipulated by the programs. A Variable has a specific data type that represents size and nature of the storage. C sharp also has special variables that come under advance programming section. Here is a quick review how we can define variables in C sharp. Learn C# Programming Tutorial for Beginners

C # Constant– The constants in C sharp are the fixed values that cannot be changed throughout the program execution. The fixed value stored for the constant is termed as Literals. Constant may be declared in the form of integers, constants, floating values, strings etc. There are enumeration constants too that are used in advanced programming.

C# Operators–An operator in C# is a special symbol that guides compiler to perform specific mathematics or logical calculations. The most popular operators defined in C# includes –

  • Arithmetic operators
  • Relational operators
  • Bitwise operators
  • Logical operators
  • Assignment operators and
  • Miscellaneous operators

Read More: C# Interview Questions and Answers The things don’t end here but it is just the beginning. In this article, we have discussed on basic concepts of the C sharp programming language that are extremely helpful for the beginners. Hope you enjoyed reading the article and learned plenty of small things that are just taken guaranteed sometimes and we fail to implement the same in our actual programming scenario. You are advised to join the training program at JanBask Training to gain in-depth knowledge on C sharp basic and advance concepts and to become a successful programmer in C sharp.

FaceBook Twitter Google+ LinkedIn Pinterest Email

    Janbask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


Trending Courses


  • AWS & Fundamentals of Linux
  • Amazon Simple Storage Service
  • Elastic Compute Cloud
  • Databases Overview & Amazon Route 53

Upcoming Class

-0 day 12 Aug 2022


  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing

Upcoming Class

-0 day 12 Aug 2022

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning

Upcoming Class

7 days 19 Aug 2022


  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation

Upcoming Class

7 days 19 Aug 2022


  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL

Upcoming Class

-0 day 12 Aug 2022


  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing

Upcoming Class

-0 day 12 Aug 2022

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum

Upcoming Class

7 days 19 Aug 2022

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design

Upcoming Class

-0 day 12 Aug 2022


  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation

Upcoming Class

1 day 13 Aug 2022

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks

Upcoming Class

15 days 27 Aug 2022

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning

Upcoming Class

28 days 09 Sep 2022


  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop

Upcoming Class

-0 day 12 Aug 2022

Search Posts


Trending Posts

Receive Latest Materials and Offers on Dotnet Course