. Net4.0 new features mainly include
I. Dynamic types
Let the Dynamic speech Runtime Library (DLR) dynamically determine the object type mode during running. With the new dynamic function of C #, you can perform interactive operations and use Dom more easily. In version 4.0, Microsoft contains a dynamic speech Runtime Library. Based on CLR, DLR provides the function of linking dynamic speech interaction operations, C # Use the dynamic keyword to access the new DLR. This is a flag for the compiler. If this flag is encountered, the compiler considers it a dynamic call rather than a general static call.
Ii. Optional parameters and naming Parameters
Optional parameters allow default values for some parameters of the method and allow users to overload the type. Therefore, all variants can be processed even if there is only one method. For example:
1 public void CreateUser(string firstName,string lastName,bool isAdmin=false,bool isTrialUser=true)
2 {
3 }
You can call this method as follows:
1 myClass.CreateUser("Bill","Ebjen");
2 myClass.CreateUser("Bill","Ebjen",true);
3 myClass.CreateUser("Bill","Ebjen",true,false);
4 myClass.CreateUser("Bill","Ebjen"isTrailUser:false);
Naming parameters may change the way code is written, which makes it easier to write and read code. For example, if you look at the File. Copy () method of the System. IO namespace, the general construction is:
File.Copy(@"C:\myTestFile.txt",@"C:\myOtherFile.txt",true);
Three parameters are used in this method, but what is actually passed to the Copy () method? Unless you know the beginning, end, and end of the method, it is difficult to determine the operation that the method will perform. By naming a parameter, you can use the parameter name in the code before providing the parameter value, as follows:
File.Copy(sourceFileName:@"C:\myTestFile.txt",destFileName:@"C:\myOtherFile.txt",overwrite:true);
Through naming parameters, you can easily read and understand the operations of this line of code. Using naming parameters does not affect the final compilation. Naming parameters are only applied to the application code.
Iii. Coordination and resistance to changes
Although earlier versions of the. net framework include covariant and variable resistance, they have extended in. Net4.0. They perform better when processing generics, delegation, and so on. For example, in previous versions, the object and array can be changed, but not the generic interface. In. Net4.0, you can use the variable resistance function for generic interfaces.
Iv. Asp. Net MVC
Asp. Net MVC is the latest in Asp. Net. It brings many surprises to the development team. Asp. Net MVC provides many developers looking forward to using Model-View-controller to create Asp. Net. Asp. Net MVC provides testability, flexibility, and maintainability for developers to build applications. Remember: Asp. Net MVC is not an alternative to Asp. Net that everyone knows and prefers. It is just another way to build applications.
Asp. Net allows you to use this new model to build an application, which is completely within the potential Framework and Visual Studio.