CSharp

From Script | Spoken-Tutorial
Jump to: navigation, search

C#


Introduction to C#

C#, known as 'C sharp' is a a computer programming language developed by Microsoft Corporation, USA. It is fully object oriented language like Java, C++, Visual Basic, Cobol etc. It is a simple, efficient, type-safe language derived from the popular C and C++ languages. It is suitable for developing Web-based applications. C# is designed for building robust, reliable and durable component to handle real-world applications. C# is expected to play a major role in developing and co-operating networks of websites. C# is one of the programming languages designed for the Common Language Infrastructure. Common Language Infrastructure is open specification. It describes the executable code and runtime environment. Recent version of C# is 4.0 developed in April 2010. We have C# 1.0 version, 1.2 version, 2.0 version, 3.0 version as well. C# has a unified type system. A unified type system means that all types, including primitives such as integers, are subclasses of the System.Object class. For example, every type inherits a ToString() method. C# comp[ilers are : Microsoft Visual C#,  

Basic Level

  1. Structure of C# program
    • The basic structure of C# program with an example
    • Example: My first C# program - to print a line
    • How to save the program
    • Use of public keyword.
    • The main() method.
    • How to Compiling a C# program
      csc filename.cs
    • How to Executing a C# program
      filename.cs

  2. Variables & Data Types
    • Defines use of keywords as identifiers like int, float etc.
    • How values are stored in variables
      • Example : int a = 10;
        Value stored in a is 10.
    • Variables and Data Types
    • Declaration, Initialization and Scope of variables
      • Example : variablename = value;
    • Boxing and Unboxing
      • Example : We will box i
        int i = 123; object o = i;

  3. Operators and Expressions
    • Understanding different operators
      • Arithmatic Operators     +, -, *, /, %, ++, --
      • Comparison Operators     ==, !=, <>, >, <, >=, <=
      • Logical Operators     && (AND), || (OR), ! (NOT)
    • Evaluation of expressions
    • Precedence of Arithmetic operators.
      • According to the priority
      • Example : High priority *, /, %, and Low priority +, -
    • Type Conversions- Converting numeric values to string and vice-versa.
      • Example : Converting short to an int. short a = 10; a = b; /*implicit conversion*/   
        Converting numeric values to string. int m = 20; string s = m.Tostring();
    • Operator Precedence and Associativity- when more than one operator is evaluated

  4. Decision Making and Branching
    • if statement - used to execute a specified condition
      • Syntax :
        if(condition)
        {
        true statement;
        }
    • if-else - used to executes a single statement or a group of statements
      • Syntax :
        if(condition)
        {
        true statement1;
        }
        else
        {
        false statement;
        }
    • Nested if-elses -
      • Syntax :
        if(condition)
        {
        true statement1;
        }
        else
        {
        if(condition)
        {
        true statement2;
        }
        else
        {
        false statement;
        }
        }
    • switch statement - use this statement to make a decision from a number of choices
      • Syntax :
        switch(integer expression)
        {
        case1 :
        execute statement1;
        case2 :
        execute statement2;
        default :
        execute this statement;
        }
    • Use of ?: operator - use this statement for making two way decisions
      • Syntax :
        expression1 ? expression2 : expression3

  5. Looping
    • for loop -used when you know in advance how many times the script should run.
      • Syntax :
        for(initialization; condition; increment \ decrement)
        {
        code to be executed
        }
    • while loop - executes a block of code while a condition is true.
      • Syntax :
        while(test condition)
        {
        code to be executed
        }
    • do-while loop - executes he body of the loop before test condition
      • Syntax :
        do
        {
        code to be executed
        }
        while(test condition);
    • foreach loop - enables us to iterate the elements in array
      • Syntax : foreach(type variable in expression) \*in is a keyword*\
        {
        code to be executed
        }
    • Jumps in loops - skipping a part of a loop

  6. Methods in C#
    • Declaring, Invoking and Nesting of Methods
    • Pass by Value & Pass by Reference
    • Method Overloading

  7. Handling Arrays
    • Creating, Declaring, Initializing Arrays
    • One Dimensional Arrays & Two Dimensional Arrays
    • ArrayList Class

  8. Manipulating Strings
    • Creating, Inserting & Comparing Strings
    • Arrays of Strings

Contributors and Content Editors

Minal