[go: up one dir, main page]

0% found this document useful (0 votes)
201 views10 pages

C# Tutorial

The document provides information about C# programming language including: - A C# tutorial that covers basic and advanced concepts for beginners and professionals. - C# is an object-oriented language that runs on the .NET framework. - The tutorial covers many C# topics like control statements, classes, inheritance, and more.

Uploaded by

Asha H. Nagoriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
201 views10 pages

C# Tutorial

The document provides information about C# programming language including: - A C# tutorial that covers basic and advanced concepts for beginners and professionals. - C# is an object-oriented language that runs on the .NET framework. - The tutorial covers many C# topics like control statements, classes, inheritance, and more.

Uploaded by

Asha H. Nagoriya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

C# Tutorial

C# tutorial provides basic and advanced concepts of C#. Our C# tutorial is designed for
beginners and professionals.

C# is a programming language of .Net Framework.

Our C# tutorial includes all topics of C# such as first example, control statements, objects
and classes, inheritance, constructor, destructor, this, static, sealed, polymorphism,
abstraction, abstract class, interface, namespace, encapsulation, properties, indexer, arrays,
strings, regex, exception handling, multithreading, File IO, Collections etc.
C# History
History of C# language is interesting to know. Here we are going to discuss brief history
of C# language.

C# is pronounced as "C-Sharp". It is an object-oriented programming language provided


by Microsoft that runs on .Net Framework.

Anders Hejlsberg is known as the founder of C# language.

It is based on C++ and Java, but it has many additional extensions used to perform
component oriented programming approach.

C# has evolved much since their first release in the year 2002. It was introduced with .NET
Framework 1.0and the current version of C# is 5.0.

Let's see the important features introduced in each version of C# are given below.
What is C#
C# is pronounced as "C-Sharp". It is an object-oriented programming language provided by
Microsoft that runs on .Net Framework.

By the help of C# programming language, we can develop different types of secured and
robust applications:

o Window applications
o Web applications
o Distributed applications
o Web service applications
o Database applications etc.

C# is approved as a standard by ECMA and ISO. C# is designed for CLI (Common Language
Infrastructure). CLI is a specification that describes executable code and runtime
environment.

C# programming language is influenced by C++, Java, Eiffel, Modula-3, Pascal etc.


languages.

C# tutorial provides basic and advanced concepts of C#. Our C# tutorial is designed for beginners and
professionals.

C# is a programming language of .Net Framework.

Our C# tutorial includes all topics of C# such as first example, control statements, objects and classes,
inheritance, constructor, destructor, this, static, sealed, polymorphism, abstraction, abstract class,
interface, namespace, encapsulation, properties, indexer, arrays, strings, regex, exception handling,
multithreading, File IO, Collections etc.
C# Features
C# is object oriented programming language. It provides a lot of features that are given
below.

1. Simple
2. Modern programming language
3. Object oriented
4. Type safe
5. Interoperability
6. Scalable and Updateable
7. Component oriented
8. Structured programming language
9. Rich Library
10. Fast speed
1)Simple
C# is a simple language in the sense that it provides structured approach (to break the
problem into parts), rich set of library functions, data types etc.

2) Modern Programming Language


C# programming is based upon the current trend and it is very powerful and simple for
building scalable, interoperable and robust applications.

3) Object Oriented
C# is object oriented programming language. OOPs makes development and maintenance
easier where as in Procedure-oriented programming language it is not easy to manage if
code grows as project size grow.

4) Type Safe
C# type safe code can only access the memory location that it has permission to execute.
Therefore it improves a security of the program.

5) Interoperability
Interoperability process enables the C# programs to do almost anything that a native C++
application can do.

6) Scalable and Updateable


C# is automatic scalable and updateable programming language. For updating our
application we delete the old files and update them with new ones.

7) Component Oriented
C# is component oriented programming language. It is the predominant software
development methodology used to develop more robust and highly scalable applications.

8) Structured Programming Language


C# is a structured programming language in the sense that we can break the program into
parts using functions. So, it is easy to understand and modify.

9) Rich Library
C# provides a lot of inbuilt functions that makes the development fast.
10) Fast Speed
The compilation and execution time of C# language is fast.

C++ vs C#
There are many differences and similarities between C++ programming language and C#. A
list of top differences between C++ and C# are given below:

No. C++ C#

1) C++ is a general purpose, case-sensitive, free-form C# is pronounced as "C-Sharp"


programming language that supports object-oriented, oriented programming languag
procedural and generic programming. Microsoft that runs on .Net Fram

2) In C++, multiple inheritance is possible through class. In C#, multiple inheritance is n


class.

3) In C++, memory management is handled manually. In C#, memory management is


automatically.

4) In C++, pointers can be used anywhere in a program. In C#, pointers can be used on

5) C++ programming is based on OOPs concept. C# programming is based on C


OOPs concept.

6) C++ is a programming language that runs on all C# is a programming language


platforms. outside Windows.

7) C++ programming can be used to create console C# programming can be used t


applications. applications, Windows appli
applications, etc.

N
Java vs C#
There are many differences and similarities between Java and C#. A list of top differences
between Java and C# are given below:

No. Java C#

1) Java is a high level, robust, secured and object- C# is an object-oriented prog


oriented programming language developed by Oracle. developed by Microsoft that run
Framework.

2) Java programming language is designed to be run on a C# programming language is de


Java platform, by the help of Java Runtime the Common Language Runti
Environment (JRE).

3) Java type safety is safe. C# type safety is unsafe.

4) In java, built-in data types that are passed by value are In C#, built-in data types that a
called primitive types. are called simple types.

5) Arrays in Java are direct specialization of Object. Arrays in C# are specialization o

6) Java does not support conditional compilation. C# supports conditional compila


preprocessor directives.

7) Java doesn't support goto statement. C# supports goto statement.

8) Java doesn't support structures and unions. C# supports structures and unio

9) Java supports checked exception and unchecked C# supports unchecked exceptio


exception.
C# Example: Hello World
In C# programming language, a simple "hello world" program can be written by multiple
ways. Let's see the top 4 ways to create a simple C# example:

o Simple Example
o Using System
o Using public modifier
o Using namespace

C# Simple Example
1. class Program
2. {
3. static void Main(string[] args)
4. {
5. System.Console.WriteLine("Hello World!");
6. }
7. }

Output:

Hello World!

Description
class: is a keyword which is used to define class.

Program: is the class name. A class is a blueprint or template from which objects are
created. It can have data members and methods. Here, it has only Main method.

static: is a keyword which means object is not required to access static members. So it
saves memory.

void: is the return type of the method. It does't return any value. In such case, return
statement is not required.
Main: is the method name. It is the entry point for any C# program. Whenever we run the
C# program, Main() method is invoked first before any other method. It represents start up
of the program.

string[] args: is used for command line arguments in C#. While running the C# program,
we can pass values. These values are known as arguments which we can use in the
program.

System.Console.WriteLine("Hello World!"): Here, System is the namespace. Console is


the class defined in System namespace. The WriteLine() is the static method of Console
class which is used to write the text on the console.

C# Example: Using System


If we write using System before the class, it means we don't need to specify System
namespace for accessing any class of this namespace. Here, we are using Console class
without specifying System.Console.

1. using System;
2. class Program
3. {
4. static void Main(string[] args)
5. {
6. Console.WriteLine("Hello World!");
7. }
8. }

Output:

Hello World!

C# Example: Using public modifier


We can also specify public modifier before class and Main() method. Now, it can be accessed
from outside the class also.

1. using System;
2. public class Program
3. {
4. public static void Main(string[] args)
5. {
6. Console.WriteLine("Hello World!");
7. }
8. }
Output:

Hello World!

C# Example: Using namespace


We can create classes inside the namespace. It is used to group related classes. It is used
to categorize classes so that it can be easy to maintain.

1. using System;
2. namespace ConsoleApplication1
3. {
4. public class Program
5. {
6. public static void Main(string[] args)
7. {
8. Console.WriteLine("Hello World!");
9. }
10. }
11. }

Output:

Hello World!

You might also like