Differences between VB.net and C # (csdn sorting)
(14:21:45)
// Global Layer
VB supports module, which is a special type in which all members are static.
C # supports static class, similar to the module of VB;
The imports Statement of VB can import static members of the class, but the using Statement of C # does not have this function.
Imports system. Math
VB can select whether the variable must be declared and whether the type must be specified (through the option Statement)
C # Is the strictest status of VB by default.
C # You can use extern alias to specify the alias of the Assembly, and use the alias limitation OPERATOR: to parse two assembly with conflicting class names.
VB does not have this function, but it can use the global keyword to obtain the namespace level Name Conflict Resolution capability.
C # You can specify a friend assembly, which is not supported by VB.
// Member Layer
VB can directly rewrite the object. Finalize method, while C # must use the Destructor syntax.
C # You can specify the target of the attribute to clearly place the attribute, while VB is determined by the position of the angle bracket. Sometimes some C # feasible syntax cannot be written.
VB can reload the operators not supported by C #: &, ^, like ,/
C # The following operators are not supported by VB: ++ ,--,!
The constructor of the subclass in VB. The constructor of the parent class is called before the fields of the subclass are initialized.
C # constructor of the Child class. initialize the fields of the Child class before calling the constructor of the parent class.
The implemnts Statement of VB can be renamed to implement the interface and change the access level.
C # not supported, but there is an explicit syntax to help
VB Function overload. The sub-class and parent class methods are considered to be at the same level.
Function overload of C #. Child classes take precedence over parent classes.
The main function of VB is automatically added with <stathread ()>, which can be changed.
// Continue member Layer
C # Custom Event can modify the add and remove rules
Besides C #, the Custom Event of VB also supports the use of the reload raiseevent statement.
VB event can directly write the event parameter and automatically generate the delege type.
The C # event must specify the delegate type.
VB supports the withevents/handles static event binding syntax and addhandler dynamic binding method.
C # events only support dynamic binding
The property of VB can contain parameters.
C # attributes cannot contain parameters
Although manual definition is not supported, VB supports transferring attribute values by reference, and C # does not.
VB can specify a property with a parameter as default, so the index syntax is supported.
C # It must be declared as an indexer, that is, the this syntax.
The default value can be specified for methods with certain optional parameters (optional) in VB.
C # Not Allowed
C # The out parameter is supported. Initialization is not required before input.
VB is not built-in
C # fixed buffer is used in the Support class, that is, fixed size members of similar Arrays
Not supported by VB
C # support function overloading based on whether the parameter has a ref/out
VB does not support this type of overload.
C # Allow Only case-sensitive functions or variables to exist
VB is case insensitive, so it is not allowed
(The member layer cannot be thought of at the moment. I will think about it again later)
// Function Layer
VB supports local static variables
C # Not Supported
VB supports variable size of the last unique array.
The array size of C # cannot be changed.
The try catch Statement of VB supports exit try to directly access finally.
C # No similar statements
VB catch can contain the when clause, and the. NET exception filter function can be used for capture.
C # This function is not supported at all
VB can use the traditional on error method to handle exceptions in an unstructured manner.
C # Only structured
C # support using the checked statement to temporarily enable or disable the integer overflow check
VB only supports project-level processing.
VB supports using function names as return variables and return
C # only return is supported.
VB's try, using, for, for each and other statements support using the variables defined by the front edge.
The corresponding statement of C # can only be defined at the beginning of the statement
C # supports unsafe syntax and limited access to pointer and stack data
Not supported by VB
C # iterator generation that supports the yield return syntax
Not supported by VB
C # support for locally generated delegate statements and the closure-based anonymous method
Not supported by VB
C # support the use of covariant and reverse Edge rules in the Process of combination of delegation and Method
In VB, only full matching rules can be used.
There are several minor differences between the cycles and branches of VB and C #.
C # supports nullable-type operators across types
VB needs to manually complete the same function
VB supports static members of the Instance sequence class.
C # only supports class-based access
VB supports calling a virtual function defined by its own type according to the rules of non-virtual functions
C # This function is not supported
Class Library Layer
VB has a very useful Microsoft. VisualBasic. dll, which implements many help functions, application framework application frameworks, and my namespaces.
C # Only visible ......
C # differentiate different functions by out/Ref or case. This is not in line with Cls.
Almost all of the features of VB are CLS compatible (even those not supported by C #). Using VB does not fundamentally affect interaction with C #.