Download presentation
Presentation is loading. Please wait.
Published byGillian Nash Modified over 9 years ago
1
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company.NET Basic Fundamentals Presented By : Muhammad Atif Hussain Deputy Manager IT (Takaful Pakistan Limited) Technologies Consultant (AUC Technologies) MCS(KU) MSCS(SZABIST) MCP MCAD MCSD MCTS (Windows, Web, Distributed Applications) MCPD (Enterprise Applications) MCT(Microsoft Certified Trainer)
2
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Overview of.NET Languages DataTypes Primitive Data Types Type Casting Arrays Multidimensional Arrays Basic Access Modifiers Abstract Data Types Variables Properties/Attributes Functions/Methods/Procedures OverLoading Agenda Constructors Inheritance Constructor Chaining Conditional Statememt Loops Namespaces Struct Enumerators Delegates Events
3
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Basic understanding of object oriented programming will help. Knowledge of C++ or Java or vb6 will help. Assumption
4
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company.NET languages provided by Microsoft –C++ –Visual Basic –C# –J# –F# (2010) Over 30.NET-compatible languages –Most are provided by 3 rd parties.NET Languages
5
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Ada APL Basic (Visual Basic) C# C C++ Java Language COBOL Component Pascal (Queensland Univ of Tech) ECMAScript (JScript) Eiffel (Monash University) Haskell (Utrecht University) lcc (MS Research Redmond) Mondrian (Utrecht) ML (MS Research Cambridge) Mercury (Melbourne U.) Oberon (Zurich University) Oz (Univ of Saarlandes) Perl Python Scheme (Northwestern U.) SmallTalk 3 rd Party Language Compiler List
6
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company TypeSize bool1 sbyte1 byte1 short2 ushort2 int4 uint4TypeSizelong8 ulong8 char2 float4 double8 decimal16 string20+ Primitive types
7
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company All Primitive types are objects Primitive Types are FCL Types –Aliases the primitives –Example: Int32 == int (C#) –Example: Int32 == Integer Primitive types
8
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Primitive types C#VBSizeMinimumMaximum sbyteSbyte1-127128 byteByte10255 shortShort2-3276832767 ushortUShort2065535 intInteger4-21474836482147483647 uintUInteger404294967295 longLong8-92233720368547758089223372036854775807 ulongULong8018446744073709551615 doubleDouble8-1.79769313486232E+3081.79769313486232E+308 decimalDecimal16-7922816251426433759354395033579228162514264337593543950335
9
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Move data of one data type to another Type Casting Long Integer Short Byte
10
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company No loss of data Byte b = 1 Short s = b Integer i = s Long l = i Implicit Type Casting byte b = 1; short s = b; int i = s; long l = I;
11
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Possible loss of precision Explicit Type Casting Short s = 256 Byte b = s short s = 256; byte b = s;
12
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Collection of similar type of Object Arrays are objects too! –ages.Length –ages.Clone() Arrays int[] x = new int[10]; int[] x = { 5, 8, 39 }; Dim x(10) As Integer Dim x() As Integer = {5, 8, 39}
13
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Rectangular Jagged Multidimensional Arrays int[,] x = new int[ 8, 8 ]; Dim x(10, 10) As Integer int[][] x= new int[2][]; x[0] = new int[ 4 ]; x[1] = new int[ 3 ]; Dim x(,) As Integer x(0, 0) = 1 x(1, 0) = 2 x(1, 1) = 3
14
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company User define data type Abstract Data Type Public Class Student End Class public class Student { }
15
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Basic Access Modifiers FormMeaning public Access not limited. private Access limited to the containing type.
16
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Variables Properties Functions (Methods/Procedure/Sub Routine) Constructors Basic Members of Abstract Data Type
17
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Specific type Hold data temporarily for reuse Instance Variable / Local Variable Variables Short s = 256 Byte b = 100 short s = 256; byte b = 100;
18
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Get and Set Guard instance variables Read Only, Write Only and Both Properties Public Property Age() As Integer Get Return _age End Get Set(ByVal value As Integer) _age = value End Set End Property class Person { private int _age; public int Age { get { return _age; } set { _age = value; } }
19
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Set of Instructions Function must return a value Function don’t return a value Functions Public Function Add(ByVal i As Integer, ByVal j As Integer) As Long Return i + j End Function public long Add(int i, int j) { return i + j; } Public Sub Print() Console.WriteLine("Name") End Sub public void Print() { Console.WriteLine("Name"); }
20
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Number of Argument / Parameter Type of Argument / Parameter Arrangement of Argument / Parameter Functions Signature
21
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Same name of functions with different Signatures Functions Overloading Public Function Add(ByVal i As Integer, ByVal j As Integer) As Long Return i + j End Function Public Function Add(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer) As Long Return i + j + k End Function public long Add(int i, int j) { return i + j; } public long Add(int i, int j, int k) { return i + j + k; }
22
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Special type of functions Called once in the life of instance Initiate the instance of class in memory Initialize instance variable with their default values Constructors Public Class Person Sub New() End Sub End Class class MyClass { public MyClass() { } }
23
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Same name of Constructor with different Signatures Constructor Overloading Public Function Add(ByVal i As Integer, ByVal j As Integer) As Long Return i + j End Function Public Function Add(ByVal i As Integer, ByVal j As Integer, ByVal k As Integer) As Long Return i + j + k End Function public long Add(int i, int j) { return i + j; } public long Add(int i, int j, int k) { return i + j + k; }
24
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Classes can extend / inherit one class at a time Inheritance ManManWomanWoman HumanHuman
25
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Generalize common functionalities to base class Generalization Public Class Human Public Function Eat() End Function End Class Public Class Man Inherits Human End Class Public Class Woman Inherits Human End Class public class Human { public void Eat() { } public class Man : Human { } public class Woman : Human { }
26
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Specialized specific functionalities to child class Specialization Public Class Human End Class Public Class Man Inherits Human Public Function Work() End Function End Class Public Class Woman Inherits Human Public Function Talk() End Function End Class public class Human {} public class Man : Human { public void Work() {} } public class Woman : Human { public void Talk() {} }
27
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Extend base class functionalities in child class Overriding (Virtual / Overridable) Public Class Human Public Overridable Sub Sleep() End Sub End Class Public Class Woman Inherits Human Public Overrides Sub Sleep() End Sub End Class public class Human{ public virtual void Sleep() { } public class Woman : Human { public overrides void Sleep() { }
28
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Extend base class abstract functionalities in child class Whole class will become abstract / MustInherit if contain any abstract / MustOverride function Overriding (Abstract / MustOverride) Public MustInherit Class Human Public MustOverride Sub Eat() End Class Public Class Woman Inherits Human Public Overrides Sub Eat() End Sub End Class public abstract class Human{ public abstract void Eat(); } public class Woman : Human { public overrides void Eat() { }
29
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Shadowing base class functionalities in child class Shadowing Public Class Human Public Sub Walk() End Sub End Class Public Class Woman Inherits Human Public Shadows Sub Walk() End Sub End Class public class Human{ public void Walk(); } public class Woman : Human { public new void Walk() { }
30
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Lock more Inheritance Sealed / NotInheritable Class Public Class Human End Class Public NotInheritable Class Woman Inherits Human End Class public class Human{ public void Walk(); } public sealed class Woman : Human { public new void Walk() { }
31
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Every constructor calls its base class constructor first All types ultimately inherit from object –Classes, enums, arrays, delegates, structs, … Constructor Chaining StreamStream MemoryStreamMemoryStreamFileStreamFileStream HashTableHashTabledoubledoubleintint ObjectObject
32
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Constructor Chaining (Cont..) Public Class A Sub New Console.WriteLine(“A”) End Sub End Class Public Class B Inherits A Sub New Console.WriteLine(“B”) End Sub End Class public class A { public A() { Console.WriteLine(“A”); } public class B:A { public B() { Console.WriteLine(“B”); }
33
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Set of rules Can implements multiple interfaces in single class Interfaces HumanHuman ManManWomanWoman PlantPlantAnimalAnimal Living Thing Non Living Thing lilylilyRoseRoseLionLionTigerTiger Interfaces Abstract Classes Sealed Classes Sealed Classes
34
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company if(x == y) { // X is equal to Y } else { //X is not equal to Y } switch(x){ case 2: //x equals 2 break; default: //x does not equal 2 break;} Conditional Statements If x == y Then ‘ X is equal to Y Else ‘X is not equal to Y End If Select Case x Case 2 ‘x is equal to 2 Case Else ‘x is not equal to 2 End Select
35
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company x = 0; do{ Console.WriteLine(x); }while(x < 0); for(x = 0;x<100;x++) Console.Write(x); Loops x = 0; while(x != 10){ Console.WriteLine(x); x++; } x = 0 While x >= 10 Console.WriteLine(x) x++; End While x = 0 Do Console.WriteLine(x) Loop While x < 0 For x = 0 To 100 Console.WriteLine(x) Next
36
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Loops int[] x = new int[] { 10, 20, 30, 40 }; foreach (int i in x) { Console.WriteLine(i); } Dim x() As Integer = {10, 20, 30, 40} For Each i As Integer In x Console.WriteLine(i) Next foreach loop Iterates over arrays or any class that implements the IEnumerable interface
37
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company
38
AUC Technologies Projects Consulting, Development, Mentoring, and Training Company Questions ?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.