This article is translated from http://www.mightywords.com/browse/details_bc05.jsp?priVateLabel =true&sku=mw8nn0uetailerid=1063
Visual Basic.net is Visual Basic - but not the Visual Basic you have been familiar with.
This means that every VB6 developer wants to be a skilled Visual Basic.NET will have a smoothing learning curve. Because new syntax and concepts, and Class on the .NET architecture needs to be understood. One question caused by this
"Since I need to learn a new language, I don't study new C #"
Before answering this question, let me first provide Visual Basic and C programming designer another problem.
"C # is a brand new language, since it is a new C # that why don't learn VB.NET?
The first question is actually hidding an idea. When VB6's programming designer asked "why I don't learn C # to replace VB.NET", the significance of his actual representative is:
"I can use VB to do a lot of good program, but C programming designers still look down on me. They earn more money, they all say that VB is the speed and ability of the Toys - VB is not as possible. They have repeatedly stressed C can do the part of VB. Now, all C programming designers have been told that the best language in the .NET environment, and C # is really like C or Java. Since I am studying VB. When NET is a lot of heart, why don't you put these efforts on C #, let me be a real program designer in the future, you can make more money like them. "
When discussing the true subject, we need to clarify the following ideas:
VB.NET is completely compatible with CLS (Common Language Spec), that is, it can fully exert the ability of the .NET execution environment. C # offers a few features that are unable to do in VB.NET, but these features are useless to most VB programming designers. Both languages are compatible with CLS, which means that you need C # features in a very small number of conditions, or you can use these C # program code in the VB.NET project.
If you accept these concepts, it is obvious that VB programming should no longer feel inferior to C or C # programming designers.
VB.NET is as good as C #, even better in some respects
You should consider the language that truly meets economic benefits
Is it in line with economic benefits?
Yes, if the two languages are like this, the factor that the decision should be economic benefits.
Economic benefit factor when evaluating language
When a professional software developer you should look for the most economical software development solution. Under this premise, you should consider the cost of the entire development cycle of the software, that is, in your heart, there should be the following consideration factors.
Learning requires time and flowers costs at the same time need to use multiple languages to displace them, so that some programming designers will reduce development efficiency (more than cost considerations) Writing the correct program code during development period ratio in other periods of correction The program code; it is cheaper to read and understand the priority of the prior cost in the cost.
Let us discuss these points
Learning takes time and costs cost
Basically I assume that VB's programming designer VB.NET, C programming C # is faster. VB's program designer basically in VB.NET as long as the difference is different from the differences, such as integers becomes 32-bit yuan, parameter transmission presets are BYVAL and no longer BYREF, etc. But I believe that VB6's programming designer is familiar with VB.NET's grammar to pass through C #.
At the same time, using multiple languages requires the displacement of your personal experience. I always write C program code in VB, write VB program code in C .
Writing the correct program code during the development period ratio in other periodic corrections; it is cheaper at cost
Which language can make you easier to complete the wrong program code? Which language can capture the most errors during writing and compile time. You will find VB.NET and C # in this regard.
In the long run, it is easy to read and understand the prior cost of degssion and maintenance.
In the following article will further explain this
Let us start comparison
In the following articles we will compare the VB.NET and C # item by item. It is necessary to emphasize the comparison between the two language differences, not the characteristics of the two languages, so the two languages have the characteristics or no need to compare, which will not appear in this article.
Data and variables
VB.NET supports all CLS standard data, C # increases the data type supported without a fixed number. The following table lists the basic type of two languages and whether it is compatible with CLS
VB.NETC # with CLS Compatible ObjectObjectStringStringy SbytenshShortyintegerintylonglongybookytey Ushortn uintn UlongnsinglefloAtyDoubledoubleyBooleanBoolyCharcharyDecimalDecimaly
The first look looks that C # wins this, but it is really important to win this should consider compatible with CLS.
When your components are compatible with CLS, you can guarantee that any other language that is compatible with CLS can access components, and attributes have no problem. Also guarantees that other CLS compatible languages can do your defined interface, inheriting your class. Also guarantees that other tools with CLS can use this component.
In other words, the CLS compatibility is the basis of .NET. C # can use unsigned variables, but should be used inside the app. You should avoid use when defining structures, methods, and attributes, etc.
VB's programming designer wants to use the unsigned type because there is a need to call the Win32 API, but .NET greatly reduces the importance of Win32 API, and automatically automatically marshalling between symbol and unsigned information through .NET. .
The decision: If you do not consider compatible with CLS, C # is winning on this topic, but vb.net wins, because in addition to violating CLS compatibility, the incompatible unsigned variable has a potential transformation error, And because of increasing complexity, it will improve maintenance costs in a long way.
SHIFT operator
C # provides LEFT-SHIFT and RIGHT-SHIFT (<< and >>) operators similar to C and C . For VB program, this is a need for less use because they are more focused on commercial applications, but I personally want Microsoft to add them to VB.NET.
The decision: C wins on this less operator
Operator overloading
C # Supports Operator Overloading, letting , -, *, etc. Operango can redefine the meaning of these types of operations after defining new data patterns.
Operator overloading is often overestimated by program designers. There is a tendency to be some C programming designers define some OverLoaded operators used by Class, but there is no meaning. You should use the OverLoaded operator in a very intuitive situation, otherwise the developer wants to remember that the meaning of some operators is difficult. Of course, for multiple OverLoading " " is a nice example. VB.NET (at least Beta1) does not support Operator Overloading.
What happens when a language with CLS is like vb.net try to use the Class of OverLoaded Operators? The operator in VB.NET cannot be used, but you can use the OverLoaded function such as op_addition or op_subtraction to do the same thing.
Most VB programming do not need Operator Overloading. C # program designers To build Assemblies used in other languages, avoid using Operator OverLoading, replaced by using simple and easy-to-understand functions.
The decision: C # wins this topic, especially for some of the programming designers in the scientific field, but this feature is not important to VB program designers
Variable initialization and Local Scoping
VB.NET automatically initials all variables into 0 or Nothing. C # Do not allow you to use this variable before you have not initialized the variable. This is not a problem under most conditions, but because VB.NET is only initialized at the time of establishment, there will be some tiny conditions. The following C # program
INT X;
For (x = 1; x <3; x )
{
INT i = 0;
Console.writeline (i); i ;}
Two 0 will appear continuously, but if the same VB.NET
DIM X as integer
For x = 1 TO 2
DIM I as integer
Console.WriteLine (i) i = 1
NEXT
Then there will be 0 and 1, of course, if you have the syntax of the following
DIM I as integer = 0
Two 0 will appear
Judgment: C # 小 赢
CONVERSION Support
VB.NET does not support from a structural assignment to define a self-order other to switch to another. Instead, it is necessary to accomplish this action with a specially named method. The following program code table lists you
Public struct SomeStruct
{
Public int x;
Public Static Explicit Operator String (SomeStruct S)
{
// deliberately let (String) the result is different, do the action of self-reservation
Return s.tostring () 10.toString ();
}
Public override string toString ()
{
Return (String);
}
Public Class Class1
{
Public static int main (String [] ARGS)
{
String resultstring;
SomeStruct S; S.x = 5;
Resultstring = (string) s;
Console.writeLine (ResultString); console.writeline (S.toString ());
Return 0;
}
Why still want an Override Tostring method? Because this kind of custom conversion is not compatible with CLS, CLS allows custom type to convert, but it is necessary to establish a method in the correct Toxxx or Fromxxx format, so that the conversion can be performed in other languages that do not support C # formats. The decision: C # little wins is not considered with CLS. I hope that Microsoft will add this feature to VB.NET.
Function syntax
VB.NET and C # have many different ways in the function call
Function return value
VB.NET maintains the function that the function does not provide the return value back to 0 or Nothing (if you return the microstrings, equal to the null string). C # Requires each of the programs that can leave, must have a clear retransmission syntax. Therefore, the C # compiler will warn you when you do not provide the required return value.
Judgment: C # provides a significant benefit to help solve the potential return value error in the function compiled
Selective parameters (Optional parameters)
C # does not provide function selective parameters, but still use OverLoading that will get the same result, so it is not calculated.
The decision: VB.NET provides Overloading that can be done with a function to do it to win this
MODULES and Static members (Members)
C # All program codes are stored in Class, VB.NET continuous support standard modules. Defining functions and varies in a standard module are present in Global in Assembly. The standard module is compatible with CLS, and C # cannot define this.
Both C # and VB.NET support static methods, attributes and fields in the Class (called Shared in VB.NET). They do not need to build objects during use, for example
Class ACLASS
{
Public static void staticMethod ()
{Console.WriteLine ("You can call you if you need to create items");}}
Then call staticMethod only needs
Aclass.StaticMethod ();
On the C # call static method, only the TYPE name, at VB.NET, you can use the Type name or the object's instance to call, the example is as follows
Class ACLASS
Public Shared Sub ShareMethod ()
Console.writeline ("You can not build a call function")
End Sub
END CLASS
Can be used through the following two types
Aclass.sharemethod ()
DIM A as new aclass ()
a.sharemethod ()
This is a philosophical consideration, and C # provides discipline: If you want to build a library that is not related to the object but consists of function, you must establish a Class to actually bring the function group together, although you Never build objects for the Type. Since all static members still need to access by TYPE name, it will force the programming designer to express the sharing of the member.
VB.NET provides greater flexibility in developers. You can establish a traditional standard module for the general function function, which can be used directly without specifying any Class or module name. You can access the Shared member of the INSTANCE of the object, but this has a danger of confused the Shared object with the Instance object.
Decoric: I will set VB.NET wins for the standard model, but still emphasize that this is a logical judgment of personal prejudice rather than convincing. I will be in less information; the program designer is confused when Shared and non-Shared members confused, and it is necessary to use a static member to use a static member to win through the Class name.
Switch and SELECT CASE syntax
Switch syntax on C # allows you to jump to a program block with a certain value or syntax. Each block is connected to a constant value. You can use multiple constant values to establish the following program Switch (i)
{
Case 4:
Case 5:
Break;
Case 6:
Case 7:
Break;
DEFAULT:
Break;
}
VB allows you to combine constant or more complicated syntax, as follows
SELECT CASE I
Case 4, 5
Case 6 TO 9
Case Else
End SELECT
Not only, VB.NET also allows you to use constants in the Select Case syntax.
The decision: VB.NET is obviously winning in this regard, although the C # simple syntax is a slightly helpful program code written by the computation.
Object syntax
The following is a discussion of syntax in VB.NET and C #. There is no score here, only one overall judgment is provided.
Patement or delivery call
All VB.NET parameters use ByVal and Byref to declare, the parameters of the C # are passaged, unless the REF keyword is announced.
OVERLOADS
If you declare two identical method names in C #, you will automatically use the OverLoads functionality, VB.NET needs to explicitly use the overloads keyword.
Call basic constructors (Base Constructors)
The syntax of the foundation of the foundation in C # is as follows
Public aclass (): base ()
{}
The grammar of VB.NET is as follows
Public Sub New ()
Mybase.new ()
End Sub
Virtual / Overridable method
C # Use the Virtual key to declare that even refer to the base Class, but is still a method of calling to the correct derived category.
VB.NET uses Overridable keywords to declare the Virtual function and requires Overrides keywords to declare derived functions to operate in Override base Class.
Abstract / Mustinherit method
C # Use the keyword Abstract keyword to mark the method you need to be made by derived Class, VB.NET uses the Mustinherit keyword to do the same indicator (simultaneously in Class and Method).
Sealed / Noinheritable Classes
C # uses the keyword SeaD to indicate the classss that cannot be inherited, VB.NET is the same thing as the Notinheritable keyword.
Other properties
C # uses the INTERNAL keyword to define the Scope of the Class or member within Assembly, while VB.NET is the same as the same declaration.
Shadowing
VB.NET When you declare the same member name as the foundation Class, you will be warned to force you Override or use Shadows Keywords (Translator Note: shadows keyword seems to have no support) Note When referring to derived clas, a method of using the base Class is used when referring to the derived class, and the basic Class's method is used to refer to the basics of instance. C # uses the new keyword to hide the method of inheriting from the base Class, and use the Override keyword to Override Virtual or Abstract Basic Class method.
Interface and inheritance
Let's take a look at C # and VB.NET how to do Class inheritance and intervene. In this example we define interface IINT, as well as base clas, as well as BCLASS derived, and do IINT interfaces. In the C # program code as follows
Namespace ConsoleApplication2
{
Using system;
Interface IINT
{
INT x ();
}
Public Class Aclass
{
Public int x ()
{Console.WriteLine ("in the X" of the foundation Class);
Return (0);
}
Public Class Bclass: ACLASS, IINT
{
INT IINT.X ()
{Console.WriteLine ("X" on the interface);
Return (0);
}
Class class1
{
Static void main (string [] args)
{
BCLASS C = New BCLASS ();
IINT I = C; C.X (); I.X (); console.readline ();}}}
C # does not need you clearly define which function is doing which interface, that is, the following program code
INT IINT.X ()
Replace
NEW public int x ()
It is considered that this x () function can not only access directly, but also the X () method of the interface.
The corresponding grammar of VB.NET is as follows
Imports system.console
Interface IINT
Function x () AS integer
End interface
Public Class Aclass
Function x () AS integer
Console.writeLine ("X" in the foundation Class)
Return 0
END FUNCTION
END CLASS
Public Class Bclass
Inherits ACLASS
Implements IINT
Private function IINTX () AS Integer Implements IINT.X
Console.WriteLine ("X" on the interface))
END FUNCTION
END CLASS
Module Module1
Sub main ()
DIM B AS New BCLASS ()
DIM I as Iint
i = B.X () i.x () console.readline ()
End Sub
End module
VB.NET needs to use the imports keyword to explicitly define which method is doing which interface method. In fact, you can do a way to make multiple different interface methods, if the interface is defined as follows:
Interface IINT
Function x () AS integer
Function Y () AS INTEGER
End interface
You can do these two, the program is as follows
Private function IINTX () AS Integer Implements IINT.X, IINT.Y
Console.WriteLine ("X" on the interface))
END FUNCTION
This real way is useful when you have two similar interfaces and share many identical methods.
Decree on the syntax of the item
The program grammar is a faith problem. Everyone likes the symptoms you are familiar with, in fact, there is no better evaluation. From the above description, you can also find that in fact, the differences between the two languages are small, both have similar functions.
But in any case, I have to make VB.NET wins on the object syntax, just in the following inheritance syntax.
Public Class Bclass: ACLASS, IINT
versus
Public Class Bclass
Inherits ACLASS
Implements IINT
And keywords inherited by the following control
Abstract, Sealed, Virtual, New
versus
Mustinherit, Notinheritable with Overridable, Overrides and Shadows
When I see the program, I want to know what it is doing, especially when I have just graduated, I want to quickly get started and solve the fuzzy mistake, or when I want to add new functions. Which syntax is easier to understand?
Visual Basic.net
Although the two are almost, VB.NET wins this.
Events
In C # You have to complete a lot of action before you can define an event, the first step you must declare the delegate Type you need to do
Public Delegate Void ChangeDeventHandler (Object Sender, Eventargs E);
This defines the signature (parameters, and parameter type of the event). The E parameter is any class inherited from any Class from Eventargs Class to include all kinds of fields of event parameters.
Then Class wants to define an event variable in the delegate type
Public Event ChangeDeventhandler Changed;
To trigger this event, Class call
Changed (this, theeventarguments);
To undertake this event, the user must define the same function as Delegate Signature
Private void ObjectChanged (Object Sender, Eventargs E)
{Console.WriteLine (e.tostring);
And need to link this function and the item that issues delegate
A.Changed = New ChangeDeventHandler (ObjectChanged);
Translator Note: The entire architecture is as follows
Namespace ConsoleApplication2
{
Using system;
Public class evtarg: system.eventargs
{
Public String Strevt;
Public evtarg (String Strin)
{Strevt = STRIN;}}
Public Delegate Void ChangeDeventHandler (Object Sender, Evtarg E);
Public Class Aclass
{
Public Event ChangeDeventhandler Changed;
Public Virtual Int x ()
{Console.WriteLine ("X in the underlying Class X with Changed Trigger Events");
Changed (this, new evtarg ("event reason ..."));
Return (0);
}
Class Evthand
{
Public void ObjectChanged (Object Sender, Evtarg E)
{Console.WriteLine ("ObjectChanged Processing Event: E.STREVT);}} Class Class1
{
Static void main (string [] args)
{
ACLASS A = New Aclass ();
Evthand h = new evthand ();
A.Changed = New ChangeDeventHandler (H.ObjectChanged);
A.x (); console.readline ();}}}
This will cause trouble, even if you use a while, it is still not adapted.
The program of VB.NET can trigger an event in exactly the same way, and can also trigger the event using the traditional way of VB6, which can be defined in the Class.
EVENT CHANGED ()
You can use any event Signature you want to define, usually use Sender, Eventargs tips as follows
Event Changd (byval e AS Object, ByVal E as Eventargs)
Triggering events can pass the RaiseEvent keyword
RaiseEvent Changd ()
The items that use events can be announced as follows
DIM WITHEVENTS B AS BCLASS
And through the following ways connect the method and events of the event and events
Sub EventHandle () Handles B.Changed
End Sub
For VB6, Event processing is an improvement, the sub function can be handled from any object, any function name, and in fact the same function can handle multiple events.
The decision: VB.NET is great. VB.NET can use the same syntax as C #, or simple syntax provides dynamic establishment properties to provide a variety of events to provide a variety of situations in any signature form.
VB command
Think about the difference between VB6 and C , C is a very concise language - it is very small. That is to say, the C programming designer depends on a large number of Chinese libraries - whether the standard C Runtime, standard template library, or writes an ATL or MFC Class Library, which writes a Windows program. C programming designers also need more understanding of Win32 APIs than VB6 software developers.
VB in history is the function, Class Libraries, and a very rich built-in function or keyword.
On .NET, C # program designers can almost all .NET Framework classes, and some Class Library for Win32 APIs. VB.NET can of course fully access these resources, but it still retains the original built-in, strong keyword collections.
However, when you decide to use VB.NET with this reason, you can consider the following C # program code.
String s = "asdf"; microsoft.visualbasic.strings.mid ((S, 2, 2));
What is this, in C # call Visual Basic's function? (Translator Note: To test this practice, C # To refer to Microsoft.visualBasic)
Yes, most VB built-in functions are now the .NET environment belongs to Microsoft.visualBasic Namespace. Because it belongs to part of the .NET Framework and is completely compatible with CLS, these functions can be used by C # or any other language. Of course, this does not mean the same, VB.NET does not need to confirm the use of the use of the full NAMESPACE and object name. Colleagues VB.NET can perform some smart actions, such as using the MID function to set the strings in the string
DIM S as string = "abcDef"
Console.writeline (MID (S, 2, 2)) MID (S, 2, 2) = "xx" console.writeline (s)
The VB programming does not feel strange in the above program code, but this is a surprising action. Because in the .NET string is never changed (they can't be modified), but VB.NET makes the entire action seem to build a new string directly under privately, and give a string variable to passing the MID function. .
The decision: VB.NET Win. From the perspective of language, this is a little win. Because other .NET Classes can be all operating in Microsoft.visualBasic. But from the economic point of view, even if it is not a big win, it is not small. Because VB's programming designers are familiar with these VB.NET commands, use them to quickly become .NET developers. This is a short-term benefit (because Even if the VB program designer chooses C # ultimately learn the function of .NET), but after all, it is a benefit. This advantage is meaningless for C in .NET to choose, this advantage is meaningless (the translator Note: Because C programming designers don't know the command provided by VB).
Other different grammar
I don't discuss the difference between VB.NET and C # basic syntax, using braces "{}" or begin ... END, with a semicolon or wrap, with for (,,) or for ... next. These are both language characteristics, nothing better. One but you are familiar with a language, it is easy to correspond to another language.
The judgment: It is completely prejudice, not a judgment here.
efficacy
I am not willing to compare the performance of two languages in the beta version, but remember two points
1.vb.net and C # are used in a large number of .NET Framework, which is the main consideration in the two language performance.
2. Both languages establish the same intermediate language (Intermediate Language IL), compile with the same Just-IN-TIME (JIT) compiler.
What is the difference between the above two points, it is difficult to say that the difference is different.
Decree: flat hand
Using or imports
C # and VB.NET provide direct (or other than reducing writing) syntax using the .NET Framework architecture object. For example, if you want to output a sentence to the Visual Studio window, you can take advantage of the following program code
System.Diagnostics.debug.writeline ("Your Error Code")
C # You can write an exact same program code, just add a semicolon.
In C # you can use the using command to avoid the need to refer to the debug object with full name, the usage is as follows
Using system.diagnostics;
This allows you to use the debug object directly, the program code is as follows
Debug.writeline ("Removed Method");
You can use Imports to do the same thing in VB.NET
Imports system.diagnostics
The first look seems to be the same, but to write the console application as an example, in C # you have to access the console.writeline function, you need to write the following console.writeline ("Your Outbox");
It should be noted here that C # must define the name of the Console object. USING syntax only provides no need to write Namespace, but it is independent of Object. In VB.NET, you can use Imports to provide directly to the object, examples are as follows
Imports system.console
So the program code can be more short
WriteLine ("Your Outbox")
The decision: VB.NET Win. The objects that can be directly referenced will bring a lot of convenience, especially when listing a string of control character.
Unmanaged code
C # allows you to define a Unmanaged Code block - you can use the metrics to access Unmanaged Memory.
It seems that this seems to be the main benefits of C #, but the following reasons are not good.
The moment's Benchmarks displays unmanaged code is not better than the Managed Code
Because the benefits of Managed Code, it is highly recommended not to use unmanaged code (such as reducing Memory Leak, Memory access error, etc.)
Conversely, the ability of the general idea is C # Direct access to Unmanaged Code does not mean that you can avoid the Marshal, which is like .NET Interop functions to Managed and Unmanaged program.
VB.NET can fully access the .NET Interop function, contain any API functions, and use all standard Marshaling properties from Managed Memory (including COM's call) Marshal data, objects and structures
VB.NET can use Unmanaged Memory, which can get or release a Unmanaged Memory block. It can reply to Unmanaged Memory. It is just less built-in keywords, but must be by the .NET InteroP method.
Judgment: C # 小 赢
Assembly organization
C # allows you to cut Assembly into multiple output files. This is used when you need to spread your application in a number of files, such as downloading through the network. VB.NET's project creates a single output (DLL or EXE).
Because some of the scattered methods can be distributed in a plurality of Assemblies, it is difficult to say that this is the main benefit of C #. Some people may also emphasize a pair of pairs of Assemblies and executable intervals to be better maintenance and spread.
Judgment: C # Win, but how big is the price
(Translator Note: According to the translator's test, this part of the VB.NET can also make multiple compiled mods. Through a manifest, it seems to be a handshake, but it seems that the two should be a flat hand. But uncertain Daniel AppleMan emphasized)
Case sensitivity
The case is also a faith problem. C programming designers will emphasize variables, methods, and instructions. The VB's program designer will enjoy the freedom of isolation and let the compiler to fix the case differences in the variables they have defined.
In addition to a matter of fact, we can not discuss this problem, CLS requires all the names of all public names. This means that C # programming designers can define different public members Method1 and Method1, from the perspective of C #, but the same is the same for other Assembly, this result will be confused. Therefore, if the C # program designer wants to consider compatibility with CLS, be careful not to distinguish between unwritten on the defined public elements. The decision: VB.NET Win is compatible with CLS
XML file
C # allows you to build an explanation file in the XML format, the format is as follows
///
/ / / For the description of Class1
/// summary>
The compiler can also make some clever judgments for XML files. For example, the SEEALSO tab not only allows the compiler to establish a code element interaction, but also confirms if the referenced element exists, that is, you can have a label as follows
If you don't find Class2 in your program, the compiler will warn you.
The judgment: The first look looks like an XML file seems to be a good idea. It is difficult to judge whether it will be popular, but the allowed code itself has the ability to explain, but let the compiler can not only judge the correctness of the document, but also the documentation of the public object and method of the programming designer is a very Attractive concept. So I think this is a major winner of C #, and I would like to ask Microsoft why vb.net?
Grammar
Some considerations have nothing to do with the language grammar itself, but still need to be considered when choosing two languages.
Background compilation and analysis
C # has a very smart analyzer that helps you mark errors when you edit the program code, such as leaking a semicolon or syntax error. But it is not a complete compiler after all, so I can't catch some errors on the language, such as
Using system. Some non-existent Namespace;
The analyzer can be accepted under the help of the compiler, and this error will be discovered during the compile time.
If you enter the same program code in VB.NET
Imports system. Some people do not exist Namespace
VB will immediately mark an error and indicate that it can't find this Namespace. VB can do this because VB's compiler is fully executed during your writing program.
The problem is: How important is it to receive an instant error? This is another degree of personal preferences. I believe that some programming designers will only write programs first, and then come back to see errors when the program build is; I have been in this way. But in my personal point of view, it will immediately improve efficiency when the development environment provides a writing program, I can determine that every line code can be compiled before moving to the next line, and I will write correctly for me. It is more efficient than the error and modification of the error in compilation period.
I solemnly suggest that you will write a program in two editing environments, believe that one but you are familiar with the background compilation of VB.NET, you will feel that there is no pain.
Judgment: VB.NET wins
Upgrade from VB6
For the program code of VB6 to VB.NET, I have emphasized that "transplant is not smart", it may not be as good as .NET established phase code, or use Interop System to come with existing COM objects or DLL Cooperation.
However, there are still some components suitable for upgrade program, especially if you want to use the .NET Free Thieading characteristics, or the Memory Leak issue, you want to achieve improved components through the memory management of .NET.
I have stressed that the transplantation in most conditions is not smart, and if you want to transfer the VB6's program code to C #, it is more stupid. VB.NET also provides upgrade elf to help handle most of the boring hard work. The most important thing is that the Visual Basic style used by the VB program code is completely different from VB.NET and C #. But unlike C #, VB.NET still supports the old error handling method, allowing you to combine new and old error handles when upgrading program, without having a large weekly redesign error handling logic. Don't make mistakes: Error processing based on Exception is a good error handling mechanism that is far from the VB old format. But if you need to upgrade the old program code, you'd better upgrade the error handling.
The decision: VB.NET wins, but only VB6
Smart format
Both C # and VB.NET provide some type of automatic autocomputer - such as a brakket that is automatically coupled or the END block syntax. Also includes automatic regeneration of some level.
However, VB.NET's compiler is much smart than C #. I immediately found that I no longer need to pay attention to the problem of deployment, just let the editor of VB.NET can do it, I can knock on any place to make up in the correct format, very cool.
C # is doing well in parentheses (so you can easily distinguish between blocks), but from the perspective of editing program, I still decide VB.NET to win.
The decision: VB.NET completely saves the trouble of formatting program
Familiar with learning costs
Familiar with grammar is the most needed programming designer, and it is also the most expensive cost of learning new languages.
Obviously, it is important to choose VB.NET or C # learning. Net is more important than the student syntax. In fact, the language is so similar, as long as you are familiar with a language, you can be familiar with another language within a few days.
In the short-term benefits are the use of the original familiar grammar, as long as you work hard to understand the .NET architecture
Judgment: VB.NET gives Visual Basic program designers, C # to C and Java programming designers
in conclusion
More important consideration
The following table lists the obvious differences. When you choose two languages, you can carefully consider it, these relatively long-term influence development costs.
Featured Winner Background Compilation and Analysis VB.NET - Especially Efficiency Functions Efficiency Functions C # - Automatically detects no return values Execution path from the old VB6 upgrade VB.NET - To take a code Upgrade to C # is simply throwing money to the water ditch XML file C # - why VB.NET is not? EVENT syntax VB.NET - Declaration is more likely to understand and reduce learning curve easier
Secondary consideration
The following table lists the secondary considerations of the two languages, unlike the effectiveness of the long-term cost of the life cycle of the software. Compare the personal factors that biased the previous version.
Features Winner Modulesvb.net - Do not need to define public functions with Class names Static / Shared member Access C # - Not confusing Shared and non-Shared Class member Object Syntaxvb.net - keywords more in line with long-term maintenance Easy to understand variable initialization C # - Need to be explicitly initialized before use, VB.NET will initialize it into 0shift Operators (<< and >>) C # - VB.NET without VB keyword VB.NET - Reduce VB6 design The learning curve of the teacher. It is not important for C programming. Familiar VB.NET to VB, C # to C and Javaswitch / Select Casevb.Net - Let Case elements can constant and variable combination unmanaged codec # - VB.NET To access Unmanaged Memoryassembly OrganizationC # - VB.NET to create a single EXE or DLL code structure (edited) VB.NET - automatic formatting, no reduced error selective parameters vb.net- -C # can be overloads to consolidation with CLS
The following table lists if you need to consider each point compatible with CLS
Featured Winner (If you consider compatibility with CLS) Winner (if you don't consider with CLS compatible) Unsigned variable vb.net - Reduce the use of errors C # - vb.net without operator Overloadingvb.net - Reduce use Error C # - VB.NET No Custom Conversionsvb.net - Reduced Use Errors C # - VB.NET No case in case size VB.NET - Reduce the conversion error full personal preference