· the NET Framework framework

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

                    [A].NET Framework framework

1 on the.Net Framework

  .net  Framework is developed by Microsoft, a commitment to agile software development (Agile software development), rapid application development (Rapid application development), the software development platform independent of platform and network transparency.

Components of 2..Net Framework

  By the common language runtime (Common Language Runtime referred to as CLR) and.Net Framework base class library (Framework Class Librily).

  The.Net Framework class library is divided into Web forms and Web SerVice

  CLR is divided into CLS (common language specification) and CTS (common type system)

  MISL Microsoft Intermediate Language Microsoft Intermediate Language

Related term 3..Net platform

Abbreviations, CLR Common Language Runtime common language runtime FCL Framework Class Libraray.Net framework class library GC Garbage Collector garbage collection mechanism Microsoft Intermediate MSIL Language Microsoft intermediate language CTS Common Type  Sysytem CLS Common Language Spectification common type system common language specification JIT Just In Time real-time compiler

 The most important feature of CTL is the base class for all types: inheritance to the public——Object.

4.C#Relationship with.NET  

  C#Is a simple. Type safe object-oriented language, developers can use it to construct the run on.Net Framework on the safe, reliable application.

5.C#Namespace

  C#The classes in the namespace is organized by. There are the following points:

      . type namespace called namespace members

      A source file can contain more than one namespace declaration

      Introduced in this paper. The namespace syntax: Using namespace name

                  C#Commonly used in the namespace

 Namespace

   Explain

System

Contains the basic class, this class defines common value types and reference types, events and event handlers, interface, attributes and exception handling

 

System.Date

 

The representation of ADO. The structure of NET type of access

 System.Text

Contains ASCLL, Unicod/UTF-7 and UTF-8 string encoding class

 System .Collections

Contains interfaces and classes. These interfaces and classes that define the various objects (such as   list, queue, digit group, hash table and Dictionary) collection.

 System.IO

For the operation of the document type 

 System.Threading

Some allow multi-threaded programming class and set 

 System.Net

Provides a simple programming interface for many of the protocols of the current network 

 The key points of the namespace name:

    The namespace name can be any valid identifier.

    The namespace can contain a symbol, for it was organized as a hierarchical namespace.

    Don't put the namespace name became associated with the name of the class or the same type of.

The namespace declarations to use the keyword namespace. The syntax is as follows:

    The name of the namespace namespace

  {

    //Define a class

  }

6.C#Classification of exception handling:

  1 syntax error

  2 run time error

  The 3 logic error

7·C#In the abnormal

  .NET provides many predefined exception class, we can also create your own exception classes. These exceptions classes in the System namespace, and are derived directly or indirectly from the System.Exception class.

                    

 

Common properties of System class.Exception

     Attribute  

 Explain

Message The text describes the error Souce lead to method invocation information application or exception object name StackTrace on the stack, he has the abnormal help track thrown

Common exception classes:

The 1 most common exception classes:

  ①Class SystemException: this class represents a.NET caused by abnormal platform, called system abnormalities, usually can not be repaired.

  ②Class ApplicationException: this class represents anomalies caused by the non fatal error occurred when the application.

2 and the relevant parameters of the anomaly

  ①Class ArgumentException: the class for the treatment of abnormal parameter is invalid.

  ②Class FormatException: the class for the treatment of abnormal parameter format error.

Abnormalities of 3 array

  ①IndexOutOfException class: the class for processing the subscript beyond exception caused by the length of the array.

  ②ArrayTypeMismatchException class: the class for processing array storage data type is not correct elements caused by abnormal.

  ③RankExecption class: the class for the exception class triggered processing dimension error

4 to count related abnormalities

  ①ArithmeticException class: the class for the abnormal related processing and arithmetic.

  ②Class DivideByZeroException: abnormal attempted to divide by zero trigger.

7.1)Try and catch block

①  Preparation of anomalies that may occur in try, such as abnormal to processing in catch

Grammar:

 try

{

  //The possible exception code

catch(IndexOutOfException e)

{

  //Exception handling code

}

*Note: This is the abnormal array index out of bounds.(IndexOutOfException)

②There is also a catch block can capture virtually all types of abnormal, known as the general catch block

Grammar:

try

{

  //May cause abnormal program code

}

catch(Exception e)

{

  //Exception handling code

}

③Multiple catch code

Grammar:

try

{

 //May cause abnormal program code

}

catch(IndexOutOfException el)

{

  //Exception handling code

}

catch(DivideByZeroException e2)

{

  //Handler block abnormal

}

.............


*Note: if you are using catch piece of universal, so can only have a general catch block.

7.2)The use of finally block

Grammar:

try

{

  //The abnormal block of code may lead to

}

catch(Exception e)

{

  //Handler block abnormal

}

finally

{

  //The final implementation of the code

}

*Look at the code:

  Do not use try... Catch blocks for process control

  No catch statement empty

  Avoid nested try... In catch block catch

7.3)The use of throw raises an exception

  Use the throw statement can cause abnormal, can also lead to a custom exception

An example:

//To judge the age range

if(age<18 || age>30)

{

  //Raise a custom defined Exceptions

  throw new InputAgeException(age+"Is not a valid age (please enter a number between 18-30)"),

}

//A custom exception InputAgeException defined procedures used are as follows:

public class InputAgeExcecption:Exception

{

  public InputAgeException(string message):base(message)

  {

  

  }

}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Hannah at November 18, 2013 - 8:43 AM