Presentation is loading. Please wait.

Presentation is loading. Please wait.

ILM Proprietary and Confidential -

Similar presentations


Presentation on theme: "ILM Proprietary and Confidential -"— Presentation transcript:

1 ILM Proprietary and Confidential - http://www.ilmservice.com

2 Native support for core.NET framework Supports traditional OO concepts such as  Inheritance  Polymorphism  Operator overloading C/C++ like syntax No more global variables C# Features ILM Proprietary and Confidential - http://www.ilmservice.com

3 using System; class Hello { static void Main() { Console.WriteLine("Hello, world"); } } A Simple C# Program ILM Proprietary and Confidential - http://www.ilmservice.com

4 Can be single dimension or multi-dimension class Test { static void Main() { int[] a1 = new int[] {1, 2, 3}; int[,] a2 = new int[,] {{1, 2, 3}, {4, 5, 6}}; int[,,] a3 = new int[10, 20, 30]; } Arrays ILM Proprietary and Confidential - http://www.ilmservice.com

5 using System; class Test { static void Main(string[] args) { if (args.Length == 0) Console.WriteLine("No arguments were provided"); else Console.WriteLine("Arguments were provided"); } If Statement ILM Proprietary and Confidential - http://www.ilmservice.com

6 using System; class Test{ static void Main(string[] args) { switch (args.Length) { case 0: Console.WriteLine("No arguments”); break; case 1: Console.WriteLine("One arguments”); break; default: Console.WriteLine("{0} arguments”); break; } } } Switch Statement ILM Proprietary and Confidential - http://www.ilmservice.com

7 using System; class Test{ static int Find(int value, int[] arr) { int i = 0; while (arr[i] != value) { if (++i > arr.Length) throw new ArgumentException(); } return i; } While Statement ILM Proprietary and Confidential - http://www.ilmservice.com

8 using System; class Test { static void Main() { string s; do { s = Console.ReadLine(); } while (s != "Exit"); } } Do Statement ILM Proprietary and Confidential - http://www.ilmservice.com

9 using System; class Test { static void Main() { for (int i = 0; i < 10; i++) Console.WriteLine(i); } } For Statement ILM Proprietary and Confidential - http://www.ilmservice.com

10 using System; using System.Collections; class Test { static void WriteList(ArrayList list) { foreach (object o in list) Console.WriteLine(o); } } Foreach Statement ILM Proprietary and Confidential - http://www.ilmservice.com

11 Classes  Used to declare reference types  Single inheritance from other classes  Multiple inheritance from interfaces  Class members can include the following Constants Fields, Methods, Properties, Indexers, Events Operators Constructors, destructors Nested Types OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com

12 Access Modifiers  Public Members are available to all code  Protrected Members are accessible only from derived classes  Internal Members are accessible only from within the same assembly  Protected Internal Members are accessible only from derived classes within the same assembly  Private Members are accessible only from the class itself OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com

13 Interfaces  Define a contract  Class that implements an interface must adhere to its contract  Interface members can consists of the following Methods Properties Indexers Events OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com

14 Properties public class Button: Control { private string caption; public string Caption { get { return caption; } set { caption = value; Repaint(); } } OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com

15 Indexers public class ListBox: Control { private string[] items; public string this[int index] { get { return items[index]; } set { items[index] = value; Repaint(); } } OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com

16 Exception Handling try { //try-statement: block of code } catch ( class-type identifier opt ) { //specific-catch-clauses: block of code } catch { //general-catch-clause: block of code } finally { // finally-clause: block of code } OO Programming With C# ILM Proprietary and Confidential - http://www.ilmservice.com


Download ppt "ILM Proprietary and Confidential -"

Similar presentations


Ads by Google