8
Answers

C# advantage

Photo of Nosipho Zungu

Nosipho Zungu

11y
1.5k
1
What advantages does c# have over visual basic?

Answers (8)

0
What does it matter if he asks the question here or asks the question there?

He probably just wants to gain more perspectives from more people.

Look at it in this manner:  It is an important question because people keep asking it.  

It's also a somewhat personal question, because sometimes, official answers do not satisfy the craving for knowledge.

He wants to know from people who have experience with both languages... from many different sources.

You should never chastise someone for asking a question.  You should maybe chastise someone more for giving a bad answer.


0
Photo of Joginder Banger
NA 10k 490.8k 11y
first of all this is not a real question. This is a basic question simply you can search on google Search Engine better then written on C# sharpcorner. I am not believe why are you post here this question, you could check every answer have a simple link another site.so what is the advantage of question post here.

don't worry and don't confused me also share a link. check a msdn official link
0
Other than unsafe code (which may yet still come), VB and C# are functionally identical.

One caveat that does not often get mentioned, and unless you study the CIL you probably wouldn't spot it:  But in C#, you always return a variable from a function with a return statement.  In VB you simply assign the function's name as a variable to the value, or you can use return.

So.

in C#:

void a(int x) {

return x + 4;

}

in VB:

Sub a(x As Integer)

a = x + 4
' or
Return x + 4

End Sub



The thing about VB code when compiled into the CIL is you will notice, if you use the return statement, that an extra stack push is made to transfer the returned variable.  If you simply assign the function's name to the variable, the extra stack push does not take place, because in VB, as originally designed, the only way to return the variable was to assign the function to its value.  The return statement was added later, and, from the looks of it, somewhat hastily.  This is why for performance critical code in VB, I still use the assign function name method.

There's some trivia for you all for the day!




0
Photo of Mongezi Sithole
NA 15 1k 11y
Language comparison Though C# and VB.NET are syntactically very different, that is where the differences mostly end. Microsoft developed both of these languages to be part of the same .NET Framework development platform. They are both developed, managed, and supported by the same language development team at Microsoft. They compile to the same intermediate language (IL), which runs against the same .NET Framework runtime libraries. Although there are some differences in the programming constructs (discussed further below), their differences are primarily syntactic and, assuming one avoids the Visual Basic "Compatibility" libraries provided by Microsoft to aid conversion from VB6, almost every command in VB has an equivalent command in C# and vice versa. Lastly, both languages reference the same Base Classes of the .NET Framework to extend their functionality. As a result, with few exceptions, a program written in either language can be run through a simple syntax converter to translate to the other. There are many open source and commercially available products for this. Features of Visual Basic .NET not found in C# Variables can be declared using the WithEvents construct. This construct is available so that a programmer may select an object from the Class Name' drop down list and then select a method from the Declarations drop down list to have the Method signature automatically inserted Auto-wireup of events, VB.NET has the Handles syntax for events Marshalling an object for multiple actions using an unqualified dot reference. This is done using the With ... End With structure XML Literals Inline date declarations by using #1/1/2000# syntax (M/dd/yyyy). Module (although C#'s sealed static classes with additional semantics, but each field has to individually be declared as static) Members of Modules imported to the current file, can be accessed with no preceding container accessor (See Now for example) The My namespace COM components and interoperability was more powerful in VB.NET as the Object type is bound at runtime, however C# 4.0 added the dynamic type which functions as a late bound form of Object. Namespaces can be imported in project level, so they don't have to be imported to each individual file, like C# In-line exceptions filtering by a Boolean expression, using "When expression" blocks. C# emulates this functionality, using a catch block followed by an if block. It is not just syntax sugar. Definition of conditional compiler constants Property methods may take parameters. Properties can be passed as reference. Enums can be defined inside interfaces. Features of C# not found in Visual Basic .NET Allows blocks of unsafe code (like C++/CLI) via the unsafe keyword and support for pointers Partial Interfaces Multi-line and intra-line comments (The Visual Studio IDE supports multi-line commenting for Visual Basic .NET.) Static classes (Classes which cannot contain any non-static members, although VB's Modules are essentially sealed static classes with additional semantics.) Can use checked and unchecked contexts for fine-grained control of overflow/underflow checking Iterative for-Loops can contain multiple conditionals. for(int i = 0; i < 10 && somethingTrue; i++) The && (and) statement in conditionals is always a short circuit. VB .Net requires the use of the special keyword AndAlso Other characteristics of Visual Basic .NET not applicable to C# Conversion of Boolean value True to Integer may yield -1 or 1 depending on the conversion used Assigning and comparing variables uses the same token, =. Whereas C# has separate tokens, == for comparison and = to assign a value VB.NET is not case-sensitive. When assigning a value to a variable with a different data type, VB.NET will coerce the value if possible. This automatic coercion can sometimes lead to unexpected results, for example: Dim i As Integer = "1" 'Compiler automatically converts String to Integer Dim j As String = 1 'Compiler automatically converts Integer to String If i = j Then 'Compiler does cast and compare between i and j MsgBox("Avoid using, but this message will appear!") 'MsgBox() can be used instead of MessageBox.show() End If It should be noted that although the default is for 'Option Strict' to be off, it is recommended by Microsoft and widely considered to be a good practice to turn 'Option Strict' "on", due to the fact it increases application performance, and eliminates the chance of naming errors and other programming mistakes. Val() function which also parses a null value while converting into double (In c# Convert.ToDouble() is used to convert any object into double type value, but which throws exception in case of a null value) CInt, CStr, CByte, CDbl, CBool, CByte, CDate, CLng, CCur, CObj and a wide variety of converting functions built in the language Other characteristics of C# not applicable to Visual Basic .NET By default, numeric operations are not checked. This results in slightly faster code, at the risk that numeric overflows will not be detected. However, the programmer can place arithmetic operations into a checked context to activate overflow checking. (It can be done in Visual Basic by checking an option) C# is case-sensitive.
0
Photo of Ehtesham  Mehmood
NA 4.2k 3.7m 11y
Check this.

http://www.vbrad.com/article.aspx?id=63
0
Photo of Vulpes
NA 98.3k 1.5m 11y
Nowadays, C# has just one advantage over VB - you can use pointers in unsafe code.

However, unless you work with memory-mapped devices or do a large amount of interop with unmanaged C/C++ libraries, it's of limited value.


0
Photo of Jignesh Trivedi
NA 61.3k 14.2m 11y
0
Photo of Lakshmanan Sethu
NA 19.3k 2.4m 11y
Please check this http://www.tangiblesoftwaresolutions.com/Articles/Differences%20Between%20VB%20and%20CSharp.html