+ All Categories
Home > Software > Dot net basics by .net development compay in india

Dot net basics by .net development compay in india

Date post: 09-Feb-2017
Category:
Upload: ifour-institute-sustainable-learning
View: 105 times
Download: 2 times
Share this document with a friend
13
iFour Consultancy Basics of .NET
Transcript
Page 1: Dot net basics by .net development compay in india

iFour Consultancy

Basics of .NET

Page 2: Dot net basics by .net development compay in india

ConstructorData TypesControl statementsProperties and MethodsStructureAbstract ClassesInterfaceDelegates and EventsError HandlingStatic and virtual Keyword

INDEX

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 3: Dot net basics by .net development compay in india

Special method of a class which is invoked automatically whenever instance or object of class is created Responsible for object initialization and memory allocation of its class Any class without constructor, the compiler will automatically create one default constructor for that class. There is

always at least one constructor in every class Constructor types

Default Constructor Parameterized Constructor Copy Constructor Static Constructor Private Constructor

Example:class SampleA{

public SampleA(){ Console.WriteLine("Sample A Test Method"); }

}

Constructor

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 4: Dot net basics by .net development compay in india

Programming language that is set of data with values having predefined characteristics Examples : integer, floating point unit number, character, string, and pointer

Value type Value type variables can be assigned a value directly Derived from the class System.ValueType E.g. int, char, and float, that stores numbers, alphabets, and floating point numbers, respectively. When you

declare an int type, the system allocates memory to store the value Reference type

The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables In other words, they refer to a memory location. Using multiple variables, the reference types can refer to a

memory location Data in the memory location is changed by one of the variables, the other variable automatically reflects this

change in value. Example of built-in reference types are: object, dynamic and string

Data Types

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 5: Dot net basics by .net development compay in india

Statement that determines whether other statements will be executedAn if statement decides whether to execute another statement, or decides which of two

statements to execute. A loop decides how many times to execute another statement. There are three kinds of loops: while loops test whether a condition is true before executing the controlled statement do-while loops test whether a condition is true after executing the controlled statement for loops are (typically) used to execute the controlled statement a given number of times

A switch statement decides which of several statements to execute

Control statements

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 6: Dot net basics by .net development compay in india

Properties Fields of objects/classes with dedicated getter/setter routines (which can be considered as

methods. There are languages that don't have properties and this behavior is achieved using a private field+get/set methods.).

Methods Similar to functions, they belong to classes or objects and usually express the verbs of the

objects/class. For example, an object of type Window usually would have methods open and close which do

corresponding operations to the object they belong.

Properties and Methods

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 7: Dot net basics by .net development compay in india

Value type data type It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure. To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program. It cannot be used as a base for other structures or classes A structure can implement one or more interfaces Structure members cannot be specified as abstract, virtual, or protected Classes are reference types and structs are value types

For example, here is the way you can declare the Book structure:struct Books{ public string title; public string author; public string subject; public int book_id;};

Structure

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 8: Dot net basics by .net development compay in india

An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share

For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class

Abstract methods have no implementation, so the method definition is followed by a semicolon instead of a normal method block

Derived classes of the abstract class must implement all abstract methods When an abstract class inherits a virtual method from a base class, the abstract class can override the virtual

method with an abstract method Classes can be declared as abstract by putting the keyword abstract before the class definition

For example:public abstract class A{ // Class members here.}

Abstract Classes

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 9: Dot net basics by .net development compay in india

It contains definitions for a group of related functionalities that a class or a struct can implement. The public definitions comprise the interface for the class, which should never change, and a contract between the creator of

the class and the users of the class It contains declarations of events, indexers, methods and/or properties. The reason interfaces only provide declarations is

because they are inherited by classes and structs, which must provide an implementation for each interface member declaredDefining an Interface:interface IMyInterface{ void MethodToImplement();}

Using an Interface:class InterfaceImplementer : IMyInterface{ static void Main() { InterfaceImplementer iImp = new InterfaceImplementer(); iImp.MethodToImplement(); } public void MethodToImplement() { Console.WriteLine("MethodToImplement() called."); }}

Interface

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 10: Dot net basics by .net development compay in india

Delegate and Event concepts are completely tied together. Delegates are just function pointers, That is, they hold references to functions

It is a class. When you create an instance of it, you pass in the function name (as a parameter for the delegate's constructor) to which this delegate will refer

Every delegate has a signature. For example: delegate int SomeDelegate(string s, bool b); The Event model in .NET Languages finds its roots in the event programming model that is popular in

asynchronous programming• The following important conventions are used with events:• Event Handlers in the .NET Framework return void and take two parameters• The first parameter is the source of the event; that is the publishing object• The second parameter is an object derived from EventArgs• Events are properties of the class publishing the event• The keyword event controls how the event property is accessed by the subscribing classes

Delegates and Events

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 11: Dot net basics by .net development compay in india

An exception is a problem that arises during the execution of a program. An exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by

zero Exceptions provide a way to transfer control from one part of a program to another. C# exception handling is built upon four keywords: try, catch, finally, and throw.

try: Block of code for which particular exceptions is activated, it is followed by one or more catch blocks catch: A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch

keyword indicates the catching of an exception finally: Used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be

closed whether an exception is raised or not throw: A program throws an exception when a problem shows up, this is done using a throw keyword

Example:try{ // statements causing exception}catch( ExceptionName ex){ // error handling code}catch( ExceptionName ex){ // error handling code}finally{ // statements to be executed }

Error Handling

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 12: Dot net basics by .net development compay in india

It’s a keyword which denotes things that are singular It often improves performance, but makes programs less flexible. These are called with the type

name. No instance is required - this makes them slightly faster. Static methods can be public or private

For E.g.static class Perls{ public static int value = 5; } It can be accessed directly by using Class For E.g. Perls.value which will return 5The virtual keyword is used to modify a method, property, indexer, or event declaration and allow

for it to be overridden in a derived class For example, this method can be overridden by any class that inherits it. For E.g.

public virtual double Area() { return x * y; }

Static and virtual Keyword

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India

Page 13: Dot net basics by .net development compay in india

Questions?

http://www.ifourtechnolab.com/

VB.NET Software Development Companies India


Recommended