[email protected] +91 9175287066
This website is always under updation with new contents
C# Tutorials
What is C#
Charactaristics of C#
Application of C#
Common Language Runtime
Command Line Argument
Program Structure
Program Coding Style
Scope of Variable
Metods in C#
Method Overloading Array
One dimensional array
Two dimensional array
Manipulating String
Class vs Structure
Creating Object
Abstract class
Abstract method
Defining an Interface
Operator Overloading
Value Types
Reference Types
C# Programming Language

Hello, and a very warm welcome to the Home and Learn computer book for C# .NET Programming (all versions, up to and including 2012). The software you need is set out below. We assume that you have absolutely no knowledge of programming. Throughout the course of this book you will learn the fundamentals of NET programming with the free edition of the Visual C# .NET software. And, of course, you will start writing your own programmers’. By the end of the book, you will have acquired a good understanding of what programming is all about, and have the ability to take it further, if you so wish. At the very least, you will have given your brain a good work out!

The .NET platform is much more than a new language, software development kit (SDK), or even an operating system. It offers powerful new services, a new processor-independent binary format, new managed languages, managed language extensions to existing languages, and the list goes on. Effectively using these new tools is not possible without a firm background of the platform that will empower your applications.

What is C#?

C# is designed for building robust, reliable and durable components to handle real world application.

Major highlights of C# are:

  • It is simplifies and modernizes C++.
  • It is the only component oriented language available today.
  • It is brand new language derived from the C/ C++ family.
  • It is the only language designed for the .NET framework.
  • It is concise, learn and modern language.
  • It is intrinsically object oriented and wed-enabled.
  • It has lean and consistent syntax.
  • It embodies today’s concern for simplicity, productivity and robustness.
  • Major parts of .NET framework are actually coded in C#.

  • Features
    1. C# is a simple ,modern, object oriented language derived from C++ and Java.
    2. It aims to combine the high productivity of Visual Basic and the raw power of C++.
    3. It is a part of Microsoft Visual Studio7.0.
    4. Visual studio supports Vb,VC++,C++,Vbscript ,Jscript .All of these languages provide access to the Microsoft .NET platform.
    5. .NET includes a Common Execution engine and a rich class library.
    6. Microsoft’s JVM equiv. is Common language run time(CLR).
    7. CLR accommodates more than one languages such as C#, VB.NET, Jscript, ASP.NET,C++.
    8. Source code --->Intermediate Language code(IL) ---> (JIT Compiler) Native code.
    9. The classes and data types are common to all of the .NET languages.
    10. We may develop Console application, Windows application, Web application using C#.
    11. In C# Microsoft has taken care of C++ problems such as Memory management, pointers etc.
    12. It support garbage collection, automatic memory management and a lot.

    Charactaristics of C#
    1. Simple
  • Pointers are missing in C#.
  • Varying ranges of the primitive types like Integer ,Floats etc.
  • Integer values of 0 and 1 are no longer accepted as Boolean values .Boolean values are pure true or false values in C# so no more errors of "="operator and "=="operator.
  • In C# there is no usage of "::" or "->" operators.

  • 2. Modern
  • C# has been based according to the current trend and is very powerful and simple for building interoperable, scable, robust applications.

  • 3. Object Oriented
  • C# supports Data Encapsulation, inheritance ,polymorphism, interfaces.
  • (int, float, double) are not objects in java but C# has introduces structures(struts) which enable the primitive types to become objects.
  • int i=1;
    string a=i To string(); //conversion (or) Boxing

    4. Type Safe
  • In C# we cannot perform unsafe casts like convert double to a Boolean.
  • Value types (primitive types) are initialized to zeros and reference types (objects and classes) are initialized to null by the compiler automatically.
  • arrays are zero base indexed and are bound checked.

  • 5. Interoperability
  • C# includes native support for the COM and windows based applications.
  • C# allows the users to use pointers as unsafe code blocks to manipulate your old code.
  • Components from VB NET and other managed code languages and directlyt be used in C#.
  • Allowing restricted use of native pointers.

  • 6. Scalable and Updatable
  • .NET has introduced assemblies which are self describing by means of their manifest. manifest establishes the assembly identity, version, culture and digital signature etc. Assemblies need not to be register anywhere.
  • Updating software components is an error prone task. Revisions made to the code. can effect the existing program C# support versioning in the language. Native support for interfaces and method overriding enable complex frame works to be developed and evolved over time.

  • Application of C#

    As pointed our earlier, C# is a new language developed exclusively to suit the features of .NET platform. It can be used for a variety of applications that are supported by the .NET platform:

  • Console applications.
  • Windows applications.
  • Developing ASP.NET projects.
  • Creating Web controls.
  • Providing Web services.
  • Developing .NET component library.

  • How does C# differet from C++

    As stated earlier, C# was derived from C++ to make it the language of choice for C and C++ programmers. C# therefore shares major parts of syntax with C++. However, the C# designer introduced a few changes in the syntax of C++ and removed a few features primarily to reduce the common pitfalls that occurred in C++ program development. They also added a number of additional features to make C# a type-safe and web-enabled language.

    How does C# differet from Java

    Like C#, java was also derived from C++ and therefore they have similar routes. Moreover, C# was developed by Microsoft as an alternative to java for wed programming. C# has browed many goods features from java, which has already become a popular internet language. However, there exist a number of difference between C# and java.

    The Common Language Runtime

    The common language runtime popularly known as CLR is the heart and soul of the .NET framework. The name CLR suggest runtime environment in which program written in C# an other .NET language are executed.

    The CLR provides number of services that included:

    1. Memory isolation for application
    2. Verification of type safety
    3. Loading and execution program
    4. Providing meta data
    5. Compilation of IL into native execution code
    6. Memory management (automatic garbage collection)
    7. Enforcement of security
    8. Managing exception and error
    9. Support for task such as debugging an profiling

    Microsoft Intermediate Language (MSIL)

    MSIL or simply IL is an instruction set into which all the .NET program are compiled. It is akin to assembly language and contains instructions for loading , storing, initializing and calling methods. When we compile a C# program or any program written in a CLS-compliant language, the source code is compiled into MSIL .

    class ProgramOne
          Public static void main()

    Class declaration
    The first line 
              Class ProgramOne

    Declaration class, which is an object-oriented construct. As stated earlier , C# is a true object oriented language and therefore, ‘everything’ must be place inside a class. Class is keyword and declare that a new definition follows. ProgramOne is a C# identifier that specified the name of the class to be define


    Let us consider the output statement of the previous sample program again


    In this, we noted that System is the namespace (scope) in which the Console class is location. A class in a namespace can be accessed using the dot operator as illustrated in the statement above. Namespaces are the way C# segregate the.NET library classes into reasonable grouping.

    /*this program uses namespace comment line*/
    Using System;  //System is namespace 
    Class ProgramTwo
      //main method start 
      Public static void main()
            Console.writeLine(“hello  world”);
      //main method ends

    Command Line Argument

    There may be occasions when we may like our program to behave in a particular way depending on the input provided at the time of execution. This is achieved in C# by using what are know as command line argument. Command line argument are parameters supplied to made methods at the time of invoking it for execution.

    /* command line argument use as input in this program */
    Using System;
    Class sample 
              Public static void main(String args[])
                    Console.Write(“Welcome  to Saplogic”);
                    Console.Write(“  ”+args[0]);
    	  Console.WriteLine(“  ”+args[1]);

    Program Structure

    C# Program may contain a number of coding block. The documentation section consist of set of comment given the name of the program.

    Since C# program required a main method as it’s starting point. The class containing the main is the essential part of the program. A simple program C# program may be contain only this part. The main method create object of a various classes and establishes communication between them.

    Program Coding Style

    C# is a freeform . we need not indent any lines to make the program work properly. C# does not care where on the line we start coding. While this may be a license for bad programming. We should try to use this fact to our advantage for designing readable program.

    For example
    System.Console WriteLine(“welcome”);
    Can be written as
    Or even as

    For accessing computer programs go to TECHNOLOGY