Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wel come To Seminar On C#.

Similar presentations


Presentation on theme: "Wel come To Seminar On C#."— Presentation transcript:

1 Wel come To Seminar On C#

2 .Net Framework Consists of Two things CLR(common language Runtime)
Framework above OS Handles execution of .Net Applications while maintaining performance FCL(Framework Class Library) Thousands of Classes for Network Prog, Data access ,Threads ,common DS, etc Pure OO design

3 MSIL(Microsoft Intermediate Lang.)
Prog .in any .Net language is converted to MSIL first & not into native code Os & hardware independent code Interpreted by CLR Similar for all .Net Language.

4 .Net Languages How to decide ? C# , C ,C++ ,Java Script ,VB , etc
CLS(common language specification) # small set of Rules Eg. no global func decl , no pointers ,no multiple inheritance, etc CTS(Common Type System) # set of standards Eg Every .net lang. must hav some basic datatypes

5 JIT(Just in time ) compiler
Using JIT , CLR converts MSIL code into native executable code Aware of each OS so can optimize code & makes Robust applications Reuses the code when used again So performance increases when program is run for a long time

6 Operating System Services
CLR Execution model VB Source code Compiler C++ C# Assembly IL Code Operating System Services Common Language Runtime JIT Compiler Native Code Managed code Unmanaged Component

7 Evolution of C# C++ Gave performance & efficiency BUT
No automatic Garbage collector Difficult to handle very large program Hard to work at windows application level VB  easy to work at windows appli. Level difficult to work at system level

8 Class & objects Similar to structure but with difference
Has attributes & methods Eg. Class Fruit { int price; float weight; public void getAttrib(); } Attributes (characteristics) price, weight Method( behaviour) getAttrib() Fruit mango; mango is reference to class mango =new Fruit( );  mango refers to an object of class Fruit & contains address of that object

9 A Short Program using System; namespace Me { class Hello
String name=“Yash”; static void Main( ) Console.WriteLine("Hello world"); console.WriteLine(“Hello {0}”,name); } // Main ends } // class Hello ends } // namespace Me ends

10 Understanding concepts
Namespace Collection of logically related classes similar to concept of Package in JAVA difference :-Unlike JAVA ,Classes of same namespace may not be in same folder Main Advantage Prevents name conflicts of classes in program Here Me is the namespace So in future if we want to reuse class Hello we can use by calling it as Me.Hello

11 Understanding concepts
Using Keyword Similar to import keyword in JAVA Tells program which classes r to be used Here Eg. using System –tells program that we want to make use of classes inside system namespace but remember that does not include classes inside sub namespaces just like Java

12 Understanding concepts
Main Method Unlike JAVA & C , there can be more than one main method in a C# program But execution will start from the main method with capital ‘M’ Unlike JAVA , Name of the program need not be same as class name containing Main ().

13 Understanding concepts
Console Class Class of System Namespace Methods WriteLine() = printf( ) , ReadLine() = scanf( ) Eg. WriteLine( “ Hello {0} , How r u ? ”, name ) ; printf in C OR WriteLine(“Hello “+name+” , How r u ? “) ;  println in JAVA

14 Diff . Bet’n Structure & Class
value type while class is of reference type may contain constructor except no argument constructor neither inherit another class nor can they be implemented can implement interfaces implicitely inherited from System.Object class instances can be created with or without using new keyword When kept small in size a struct is more efficiently used by the system than class

15 Abstract class an incomplete class
one or more abstract (incomplete methods) i,.e method with signature but no implementation can’t be instantiated i.e its object can’t be created but reference can be Can be inherited Its subclass must implement all abst. Methods of Abstract class Eg . Abstract class A { int a1; public abstract int add(int x , int y); } class B : A { int b1; public int add(int x, int y) { int z=x+y; return z; if A a = new A( );  Error

16 Object Oriented Language
Inheritance Eg Class A { int a1; int a2; public void Get(); } Class B : A

17 Object Oriented Language
Inheritance Like Java & unlike C++ , C# does not allow multiple inheritance The Object class defined in System namespace is the ultimate base of each class Interfaces in C# can inherit more than one interface  Sealed keyword prevents class from being inherited = final keyword in Java

18 Access Modifiers Private-can be accessed within the class
Protected-can be accessed from the containing class & types inherited from them Public-Anyone can access Protected internal - anything within the project can access or types inherited from them Internal-anything within the project can access cannot apply acces modifiers to namespaces

19 properties Built in support for accessing private members of a class
Suppose “name “ is one of the private fields of class Public string Name { Get return name; } Set Name=value; Use method stu.Name = “Yash” ; correct stu.name=“Yash”; incorrect Convention – Property must be of same name as field name but with letter as capital letter

20 delegates reference to a methods
Similar to function pointer concept in C & C++ Delegates can be made to a signature of method Three Properties of Delegate 1-signature of method that a delegate points to Eg. int Add(int a, int b); int Sub(int c, int d); Here both methods have same signature So delegate int Mydelegate(int a, int b); 2- reference of delegate that points to a method Mydelegate arith; 3-Actual methods reference by the delegate arith = new Mydelegate(Add);

21 Exception handling Exceptions- They r the runtime errors causing the program to terminate prematurely Eg Public void Main() { int d=2; int c=0; program will terminate unexpectedly To prevent this Exception Handling is used Mechanism System.Exception - Base class for all exceptions Throw keyword – Methods can throw exception explicitly “Try” and “catch” block should be used . Single try block is not allowed suspected code must be in Try block while measures to handle exception must be in catch block

22 Mechanism (cont.) Exception handling
finally – code must be executed whether exceptions occur or not Eg. Freeing of resources, closing opened files, etc If we miss, CLR will handle exception for us


Download ppt "Wel come To Seminar On C#."

Similar presentations


Ads by Google