C# and .NET Framework - ?· 23 Architecture of ADO.Net 54 24 ADO.NET Connected and Disconnected Models…

Embed Size (px)

Text of C# and .NET Framework - ?· 23 Architecture of ADO.Net 54 24 ADO.NET Connected and Disconnected...

  • A Course Material on

    C# and .NET Framework

    By

    Mr.SATHISHKUMAR.J

    ASSISTANT PROFESSOR

    DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

    SASURIE COLLEGE OF ENGINEERING

    VIJAYAMANGALAM 638 056

  • QUALITY CERTIFICATE

    This is to certify that the e-course material

    Subject Code : CS2041

    Subject : C# and .NET Framework

    Class : IV Year CSE

    being prepared by me and it meets the knowledge requirement of the university curriculum.

    Signature of the Author

    Name: J.SATHISHKUMAR

    Designation: ASSISTANT PROFESSOR

    This is to certify that the course material being prepared by Mr.J.Sathishkumar is of adequate quality.

    She has referred more than five books among them minimum one is from abroad author.

    Signature of HD

    Name: J.Sathishkumar

    SEAL

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    1 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    TABLE OF CONTENTS

    S.NO DATE TOPIC PAGE

    NO

    UNIT-I

    1 Review OOP Concept 4

    2 Structure of.NET Framework 7

    3 Simple Input and Output Operations 10

    4 Getting and displaying input/ output 11

    5 Operators 12

    6 Arrays 16

    7 Structures 17

    UNIT-II

    8 Inheritance in C# 20

    9 Namespace 24

    10 Polymorphism 26

    11 Interfaces 27

    12 Delegataes 29

    13 Publish /Subscribe design patterns 32

    14 Operator Overloading 33

    UNIT-III

    15 C# Concepts for creating Data Structures 37

    16 Stream and its usage of C# 39

    17 Filestreams 39

    18 File Operation in C# 41

    19 Multithreading 46

    20 S Synchronization. 47

    UNIT-IV

    21 XML Data 51

    22 Reading & Writing XML File 52

    23 Architecture of ADO.Net 54

    24 ADO.NET Connected and Disconnected Models 55

    25 XML and ADO.NET 59

    26 Simple and Complex Data Binding 60

    27 Data Grid View Class. 63

    UNIT-V

    28 Application Domains 66

    29 Remoting 67

    30 Leasing and Sponsorship 68

    31 .NET Coding Design Guidelines 68

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    2 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    32 Assemblies 69

    33 XML web service application 70

    WSDL 70

    SOAP 72

    APPENDICES

    A Glossary 73

    B Question Bank 90

    C Previous Year University question papers 103

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    3 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    CS2041 C# AND .NET FRAMEWORK L T P C 3 0 0 3

    UNIT I 9 Review of OOP Concepts - Overview of .NET Framework - Basic Elements of C# - Program

    Structure and simple Input and Output Operations Operators and Expressions

    Statements Arrays and Structures.

    UNIT II 9 Inheritance - Namespace Polymorphism Interface and Overloading Multiple Inheritance

    Property Indexes Delegates Publish/Subscribe Design Patterns- Operator Overloading-

    Method Overloading

    UNIT II 9 C# Concepts for creating Data Structures - File Operation File Management systems Stream

    Oriented Operations- Multitasking Multithreading Thread Operation Synchronization.

    UNIT IV 9 Working with XML Techniques for Reading and Writing XML Data - Using XPath and

    Search XML - ADO.NET Architecture ADO.NET Connected and Disconnected Models

    XML and ADO.NET Simple and Complex Data Binding Data Grid View Class.

    UNIT V 9 Application Domains Remoting Leasing and Sponsorship - .NET Coding Design Guidelines

    Assemblies Security Application Development Web Services - Building an XML

    Web Service - Web Service Client WSDL and SOAP Web Service with Complex Data Types

    Web Service Performance.

    TOTAL = 45

    TEXT BOOKS:

    1. S. Thamarai Selvi and R. Murugesan A Textbook on C# , Pearson Education,2003.

    2. Stephen C. Perry Core C# and .NET, Pearson Education,2006.

    REFERENCES: 1. Jesse Liberty, Programming C#, Second Edition, OReilly Press, 2002.

    2. Robinson et al, Professional C#, Fifth Edition, Wrox Press, 2002.

    3. Herbert Schildt, The Complete Reference: C#, Tata McGraw Hill, 2004.

    4. Andrew Troelsen, C# and the .NET Platform, A! Press, 2003.

    5. Thuan Thai and Hoang Q. Lam, . NET Framework Essentials, Second

    Edition, OReilly, 2002.

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    4 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    UNIT I

    1.Review OOP Concept

    Class is like the BLUEPRINT to make something.

    Object is made from a BLUEPRINT. So you can make many Objects from 1 Class.

    When you make an OBJECT from a CLASS, it is called an INSTANCE of a Class.

    Objects have

    1. Name like a name you give an object Identifier 2. Attributes like specific characteristics for the object Variables 3. Behaviours like actions the object can perform Instance Methods

    UML Unified Modeling Language

    Because in Java everything is wrapped in a class, it can get very confusing!

    We can use UML to show the structure of a Class.

    Name of Class

    Attributes/Variables : Data-Type

    Behaviour/Methods (param name: param data-type, etc ): Return-Type

    plus or minus represent the ACCESS MODIFIERS, which are:

    + public

    - private

    Example

    house1 OBJECT

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    5 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    House

    -number: int

    -street: String

    -colour: String

    -garage: boolean

    House(n: int, s: String, c: String, g: boolean)

    +getNumber(): int

    +getStreet(): String

    +getColour(): String

    +haveGarage(): boolean

    +paintHouse(String colour):void

    number = 10

    street = Nabob Cres.

    colour = beige

    garage = false

    plus + Behaviours/Methods

    House CLASS

    house2 OBJECT

    number = 2

    street = Milita Cres.

    colour = blue

    garage = true

    plus + Behaviours/Methods

    Attributes /

    Variables

    Behaviours /

    Methods

    Name of Class

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    6 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    Encapsulation and Access Modifiers

    We use public and private to add security to VARIABLES and METHODS. This is called

    ENCAPSULATION.

    public means a VARIABLE or METHOD can be used INSIDE & OUTSIDE the class

    private means a VARIABLE or METHOD can only be used INSIDE the class

    Public Example Private Example

    public class Student

    {

    public int age =0;

    } // Student class

    public class Main

    public class Student

    {

    private int age =10;

    public void changeAge(int num){

    if (num>0){

    age=num;

    }

    }//end changeAge

    public int getAge(){

    return age;

    }//end getAge

    } // Student class

    public class Main

    {

    name = john

    mark1 = 50

    mark2 = 70

    average = 60

    plus + Behaviours/Methods

    name = tom

    mark1 = 80

    mark2 = 75

    average = 77.5

    plus + Behaviours/Methods

    student2 OBJECT

    Student

    -name: String

    -mark1: int

    -mark2: int

    -average: double

    Student(n: String)

    +setMarks(x : int, y : int) : void

    +calcAverage() : void

    +message() : String

    Student CLASS

    Name of Class

    Attributes /

    Variables

    Behaviours /

    Methods

    student1 OBJECT

  • C# and .NET FRAMEWORK IV YEAR/ VII SEM DEPT OF CSE

    7 J.SATHISHKUMAR, AP/CSE 2015-2016(ODD SEM)

    {

    public static void main (String[] args)

    {

    //can change age to anything

    //they want! BAD THING!

    s.age = -99;

    System.out.println(s.age);

    } // main method

    } // Main class

    public static void main (String[] args)

    {

    Student s = new Student();

    //s.age = 100; no longer possible

    because private

    //wont change to a negative because

    //the method checks for that

    s.changeAge(-100);

    System.out.println(s.getAge());

    } // main method

    } // Main class

    Why are the variables private and methods public?

    Because we want to protect variables from being accessed directly; so they cant be changed or

    used incorrectly. To GET a value from a variable or to GIVE a variable a value we write public

    methods to do this.

    For example we could have changed the setMarks method from the Student Class to prevent users

    from entering an incorrect value:

    public void setMarks(int x, int y){

    mark1 = x;

    mark2 = y;

    }//end setMarks

    public void setMarks(int x, int y){

    if (x > 100) {