Microsoft 'NET Runtime - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Microsoft 'NET Runtime

Description:

ILM Proprietary and Confidential - http://www.ilmservice.com ... OO Programming With C#. ILM Proprietary and Confidential - http://www.ilmservice.com ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 17
Provided by: farhanm
Category:

less

Transcript and Presenter's Notes

Title: Microsoft 'NET Runtime


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

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

ILM Proprietary and Confidential -
http//www.ilmservice.com
4
Arrays
  • 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 int10, 20, 30

ILM Proprietary and Confidential -
http//www.ilmservice.com
5
If Statement
  • using System
  • class Test
  • static void Main(string args)
  • if (args.Length 0) Console.WriteLine("No
    arguments were provided") else Console.WriteLi
    ne("Arguments were provided")

ILM Proprietary and Confidential -
http//www.ilmservice.com
6
Switch Statement
  • 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

ILM Proprietary and Confidential -
http//www.ilmservice.com
7
While Statement
  • using System
  • class Test
  • static int Find(int value, int arr)
  • int i 0 while (arri ! value)
  • if (i gt arr.Length) throw new
    ArgumentException() return i

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

ILM Proprietary and Confidential -
http//www.ilmservice.com
9
For Statement
  • using System
  • class Test
  • static void Main()
  • for (int i 0 i lt 10 i) Console.Write
    Line(i)

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

ILM Proprietary and Confidential -
http//www.ilmservice.com
11
OO Programming With C
  • 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

ILM Proprietary and Confidential -
http//www.ilmservice.com
12
OO Programming With C
  • 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

ILM Proprietary and Confidential -
http//www.ilmservice.com
13
OO Programming With C
  • 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

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

ILM Proprietary and Confidential -
http//www.ilmservice.com
15
OO Programming With C
  • Indexers
  • public class ListBox Control
  • private string items
  • public string thisint index get
  • return itemsindex
  • set
  • itemsindex value Repaint()

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

ILM Proprietary and Confidential -
http//www.ilmservice.com
Write a Comment
User Comments (0)
About PowerShow.com