Presentation is loading. Please wait.

Presentation is loading. Please wait.

BY BOWYA G.  This International Standard is based on a submission from Hewlett-Packard, Intel, and Microsoft, that describes a language called C#. 

Similar presentations


Presentation on theme: "BY BOWYA G.  This International Standard is based on a submission from Hewlett-Packard, Intel, and Microsoft, that describes a language called C#. "— Presentation transcript:

1 BY BOWYA G

2  This International Standard is based on a submission from Hewlett-Packard, Intel, and Microsoft, that describes a language called C#.  It was developed within Microsoft.  The first widely distributed implementation of C# was released by Microsoft in July 2000, as part of its.NET Framework initiative.  Its runs with Common Language Infrastructure

3  The language is intended for use in developing software components suitable for deployment in distributed environments.  C# is intended to be a simple, modern, general- purpose, object-oriented programming language.  Support for internationalization is very important.  This programmers already familiar with C and C++.

4  C# is intended to be suitable for writing applications for both hosted and embedded systems.  Although C# applications are intended to be economical with regards to memory and processing power requirements, the language was not intended to compete directly on performance and size with C or assembly language.  The development of this standard started in November 2000.

5  C# supports two kinds of types: value types and reference types.  Value types include simple types (e.g.,char, int, and float), enum types, and struct types.  Reference types include class types, interface types,delegate types, and array types.

6  Value types differ from reference types in that variables of the value types directly contain their data, whereas variables of the reference types store references to objects.  The reference types, it is possible fortwo variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable. With

7 using System; class Class1 { public int Value = 0; } class Test { static void Main() { int val1 = 0; int val2 = val1; val2 = 123; Class1 ref1 = new Class1();

8 Class1 ref2 = ref1; ref2.Value = 123; Console.WriteLine("Values: {0}, {1}", val1, val2); Console.WriteLine("Refs: {0}, {1}", ref1.Value, ref2.Value); } Output:  Values: 0, 123  Refs: 123, 123

9 TypeDescriptionExample stringString typestring s = "hello"; sbyte8-bit signed typesbyte val = 12; short16-bit signed typeshort val = 12; byte8-bit signed typebyte val1 = 12; ushort16-bit signed typeushort val1 = 12; int32-bit signed typeint val = 12; Long64-bit signed typeLong val=122; floatSingle-precision floating point type float val = 1.23F; doubledouble Double- precision floating point type double val1 = 1.23; double val2 = 4.56D;

10  Arrays may be single-dimensional or multi- dimensional. Both.rectangular. and.jagged. arrays are supported.  Jagged array is important concept in c#.  creates a single-dimensional array of int values, initializes the array elements, and then prints each of them out. Ex : int[] arr = new int[5];

11 using System; class Test { static void Main() { int[] arr = new int[5]; for (int i = 0; i < arr.Length; i++) arr[i] = i * i; for (int i = 0; i < arr.Length; i++) Console.WriteLine("arr[{0}] = {1}", i, arr[i]); }

12 Output : arr[0] = 0 arr[1] = 1 arr[2] = 4 arr[3] = 9 arr[4] = 16 here int[] used in the previous example is an array type.

13  Class members can include constants, fields, methods, properties, events, indexers, operators, instance constructors, destructors, static constructors, and nested type declarations.  Class declarations define new reference types. A class can inherit from another class, and can implement interfaces.

14 FormMeaning publicAccess not limited protectedAccess limited to the containing class or types derived from the containing class internalAccess limited to this program privateAccess limited to the containing type

15  A destructor is a member that implements the actions required to destruct an instance of a class.  Destructors cannot have parameters, they cannot have accessibility modifiers, and they cannot be called explicitly.  The destructor for an instance is called automatically during garbage collection.

16 using System; class Point { public double x, y; public Point(double x, double y) { this.x = x; this.y = y; } ~Point() { Console.WriteLine("Destructed {0}", this); } public override string ToString() { return string.Format("({0}, {1})", x, y); }

17  A static constructor is a member that implements the actions required to initialize a class.  Static constructors cannot have parameters, they cannot have accessibility modifiers, and they cannot be called explicitly  The static constructor for a class is called automatically.

18 using Personnel.Data; class Employee { private static DataSet ds; static Employee() { ds = new DataSet(.); } public string Name; public decimal Salary;. }

19


Download ppt "BY BOWYA G.  This International Standard is based on a submission from Hewlett-Packard, Intel, and Microsoft, that describes a language called C#. "

Similar presentations


Ads by Google