Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Basics of .net framework by software outsourcing company india

This presentation is about .NET Framework and its usability for custom and web development by - software outsourcing company India - iFour Technolab Pvt. Ltd - http://www.ifourtechnolab.com

  • Be the first to comment

  • Be the first to like this

Basics of .net framework by software outsourcing company india

  1. 1. iFour ConsultancyBasics of .Net
  2. 2. Constructor is a special method of a class which will invoke automatically when instance or object of class is created. Constructors are responsible for object initialization and memory allocation of its class. If we create 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. Basically constructors are 5 types those are  Default Constructor  Static Constructor  Private Constructor  Parameterized Constructor  Copy Constructor Example: class SampleA { public SampleA() { Console.WriteLine("Sample A Test Method"); } } Constructor http://www.ifourtechnolab.com Software development company india
  3. 3. A data type in a coding language is a set of data with values having predefined characteristics. Examples of data types are: character, string, integer, floating point unit number, and pointer. Usually, a limited number of such data types come built into a language. The language usually specifies the range of values for a given data type, how the values are processed by the computer, and how they are stored. Two types of Datatypes are present in .net Application i. Reference type - The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables. n other words, they refer to a memory location. Using multiple variables, the reference types can refer to a memory location. If the 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. ii. Value type - Value type variables can be assigned a value directly. They are derived from the class System.ValueType. The value types directly contain data. Some examples are char ,int, and float, which stores numbers, alphabets, and floating point numbers, respectively. When you declare an int type, the system allocates memory to store the value. Data Types Software development company indiahttp://www.ifourtechnolab.com
  4. 4. A control statement is a statement that determines whether other statements will be executed. o An if statement decides whether to execute another statement, or decides which of two statements to execute. o A loop decides how many times to execute another statement. There are three kinds of loops: o for loops are (typically) used to execute the controlled statement a given number of times. o while loops test whether a condition is true before executing the controlled statement. o do-while loops test whether a condition is true after executing the controlled statement. o A switch statement decides which of several statements to execute. Control statements Software development company indiahttp://www.ifourtechnolab.com
  5. 5. Properties are as in everyday language and technically are 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 ("member functions") are similar to functions, they belongs to classes or objects and usually expresses 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 Software development company indiahttp://www.ifourtechnolab.com
  6. 6.  In .Net, a structure is a 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. Few Properties of structure  Unlike classes, structures cannot inherit other structures or classes.  Structures 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 Software development company indiahttp://www.ifourtechnolab.com
  7. 7. 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 Software development company indiahttp://www.ifourtechnolab.com
  8. 8. An interface 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. An interface looks like a class, but has no implementation. The only thing it contains are 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 declared. Defining 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 Software development company indiahttp://www.ifourtechnolab.com
  9. 9. Delegate and Event concepts are completely tied together. Delegates are just function pointers, That is, they hold references to functions. A Delegate 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 basic foundation behind this programming model is the idea of "publisher and subscribers." In this model, you have publishers who will do some logic and publish an "event." Publishers will then send out their event only to subscribers who have subscribed to receive the specific event. • The following important conventions are used with events: • Event Handlers in the .NET Framework return void and take two parameters. • The first paramter 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 Software development company indiahttp://www.ifourtechnolab.com
  10. 10. The More quoted word is Exception Handling and is defined as: 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: A try block identifies a 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: The finally block is 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 e1 ){ // error handling code} catch( ExceptionName eN ){ // error handling code} finally{ // statements to be executed } Error Handling Software development company indiahttp://www.ifourtechnolab.com
  11. 11. Static is a keyword which denotes things that are singular. They are part of no instance. Static 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 Eg: static class Perls { public static int value = 5; } It can be accessed directly by using Class For Eg: Perls.value which will return 5. The 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 Eg: public virtual double Area() { return x * y; } Static and virtual Keyword Software development company indiahttp://www.ifourtechnolab.com
  12. 12. In the common language runtime (CLR), the garbage collector serves as an automatic memory manager. It provides the following benefits:  Enables you to develop your application without having to free memory.  Allocates objects on the managed heap efficiently.  Reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations. Managed objects automatically get clean content to start with, so their constructors do not have to initialize every data field.  Provides memory safety by making sure that an object cannot use the content of another object. Garbage Collection Software development company indiahttp://www.ifourtechnolab.com
  13. 13. Thank you Software development company indiahttp://www.ifourtechnolab.com

×