a companion discussion area for blog.codinghorror.com

VB vs. C# -- FIGHT!


There is a VB equivalent to:
public void foo(string arg)
if (null == arg) return;
// code here

Write it like this (as of .NET 2.0):

Public Sub Foo(ByVal arg As String)
If arg is Nothing Then exit sub
’ code here
End Sub


oups… looks like I’ve jumped up the screen tonight :slight_smile:
was looking for a benchmark comparison between VB6 and C# and all i get is VB.NET VS CSHARP that both does the same SMILE !
A small article and a big bunch of comments for it… well let me say that’s all folk guys.
When you don’t need speed but need design patterns, maintenability, interoperability… everything that’s end with bility… just use .NET or .JAVA. But for speed let’s say that c with no sharp is better and eventually c++… and eventually VB if you don’t want to deal with pointers and memory stuff. What we see today is .NET using COM interop and low level black boxes. I always keep in mind that the first and only thing is the customer SMILE so.
All this “verbiage” around who’s the best language is just … You can do … with C# to !
Sorry for that bad spelling frenchy token ring stuff!


Ok, I just read through 3 years worth of posts here and I didn’t have my question answered.

Background: I pretty much just started into the world of programming. I am mainly interested in web development but, it’s all good to me. I have done some research in most main-stream languages and have been mostly working with PHP for my server-side stuff.

I have been feeling like the .NET path is the way to go from here. I have always known that the best programmers don’t stick to just one language. Why else would there be so many? Anyway, to cut to the chase, I know to truely be an employable developer, I need to know both C# and VB.

My question to the masters is: which should I learn first?

Oh, and just so you know, I’m already leaning toward C#, just because of the easy transition into other C based languages.

I would love any feedback though, thanks already!


Xaq - it doesn’t matter which you learn first. They’re almost the same language except for differences in syntax. You could learn both side-by-side I suppose without much extra effort.


I think it’s a more personal preference thing. If I came from a background of C/C++, I would prefer C#, but considering my background is from VB, definately I would look at first at VB.NET.
Like what most have said, choose the right tool for the right task.
A C++ syntax would fall as a 3rd GL, and a VB syntax would fall as 4th GL. Isn’t it?



Jeff != jeff even in the English Language. The reason one places the first character in upper case is because of a particular reason. Read up on the history of why proper nouns are made upper case.

It does boil down to a class of society issue, but that, in the end this debate is about just that: C# society vs. VB society.


well. (clears throat) some interesting banter here. now on with what’s important. would a developer please convert the following to VB for me. muchas gracias mi amigos.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Reflection;

namespace ClassLibrary1
public static class MyExtenders
public static DataTable ToDataTable(this IEnumerable collection)
DataTable dt = new DataTable();
Type t = typeof(T);
PropertyInfo[] pia = t.GetProperties();
//Create the columns in the DataTable
foreach (PropertyInfo pi in pia)
dt.Columns.Add(pi.Name, pi.PropertyType);
//Populate the table
foreach (T item in collection)
DataRow dr = dt.NewRow();
foreach (PropertyInfo pi in pia)
dr[pi.Name] = pi.GetValue(item, null);
return dt;


I hope this is what you were looking for Adam. Good Luck.

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Data
Imports System.Reflection
Imports System.Runtime.CompilerServices

Namespace ClassLibrary1

Public Module MyExtenders

    Extension() _
    Public Function ToDataTable(Of T)(ByVal collection As IEnumerable(Of T)) As DataTable

        Dim dt As New DataTable

        Dim ty As Type = GetType(T)
        Dim pia As PropertyInfo() = ty.GetProperties()

        For Each pi As PropertyInfo In pia
            dt.Columns.Add(pi.Name, pi.PropertyType)

        For Each item As T In collection

            Dim dr As DataRow = dt.NewRow

            For Each pi As PropertyInfo In pia
                dr(pi.Name) = pi.GetValue(item, Nothing)



        Return dt

    End Function

End Module

End Namespace



The code you posted doesn’t compile, unless I missed something.


public static DataTable ToDataTable(this IEnumerable collection)

read as follows

public static DataTable ToDataTableT(this IEnumerableT collection)



C# programers are real snobs only, they dont know about standered code modules of vb.net.


I put the above statement after seeing previous 2/3 posts only. so i want to change that to ‘MOST OF THE SNUB C# PROGRAMMERS ARE SEEMS TO BE SIMPLY SNOBS’


I think you misunderstand. C#'s syntax is and I think we can all agree is very similar to other languages, VB’s syntax isn’t. Thus if your planning on venturing forth into more powerful languages C# is the right choice.


Oh and Desdubler, we all know english is much more complex then real syntax.


If one or the other language was so superior to the other then why are there multiple free code translators available online?

Reason - just about any logic flow present in one language can be similarly represented in the other language, and vice versa.

They are different styles of language, symbolic vs linguistic.

Both languages use a bit of the the other language’s style to accomplish certain things that may have come to standardized practice in the other language.

And there are some tasks that each syntax style has weaknesses with.

Syntax is just not that important. It’s all about logic and architecture.


what a funny argument. For everybody involved. I have been coding in microsoft environments since 1992. I’ve used Access Basic, All versions of visual basic, VBA, vbScript, ASP 1.0 - Asp.net 3.5

The issue you should be talking about has absolutely nothing to do with what language you are coding in. The real cost to projects is the ineptidute that exists out there in database design and effective database coding. This of course presumes that you are coding to a database. Not sure what you are doing in the business worlds if that is not the case.

Somebody else made the point, and other in different ways - VB is superior because in the long run - people are replacable, VB is readable and here to stay and (assuming the code is clear, the database is designed well) newcomers will easily be able to come up to speed to take over.

It is, in my experience, not a language issue, but a database issue. Why do you think the mainframe guys were being replaced up the wazoo in the first place - DATABASE advances. How many coders out there are expert database deigners, architects and analysts? not enough.


I can’t believe I just read this entire discussion. What I take away from it is, LOL I’m glad I didn’t waste time arguing one way or the other for something which actually doesn’t matter one iota when compared to the difference a developers skill has on prductivity.


I hear this will change in 2010, but right now, C# has anonymous delegates, with lexical closure, and VB does not. C# gained this feature in 2.0, and it was what got me to make the jump from VB.

If you know what you’re doing, you can use this feature to dramatically reduce code duplication, and build nifty things like domain-specific languages. For example, I recently built a DSL for validating Excel files. I can say things like:

either(hasval(A), both(hasval(B), minlen(C, 3)))

and for each row it will report an error unless either column A has a value, or both B has a value and C has a minimum length of 3.

I’ve got all sorts of validators and the whole thing is about four pages of code. I have no idea how I would go about doing it in VB.


Fantastic! Absolutely fantastic. I’ve just spent the last 20 minutes reading through this thread. What a great, and pointless, war you are all having.

I am an end-user AND a developer and guess what…? The stuff I use - but did not develop (that I know has been developed in VB or CS) serves my (and my organisation, and my friends’ and their organisations) needs pretty well.

Anyway, keep it up. I want to read more.


WOW, this is a piece of history. 2004-2009


Huh? I’m used to C# and VB.Net on MSVS 2008. There really isn’t that much difference between the two. There are only a few things you can do in C# that you can’t do in VB.NET, but so far they haven’t hindered my development efforts in VB.NET

One thing I will say against VB is that right now you have to be more careful with its loose typing. As a programmer I have to be more disciplined. There is nothing like a strongly typed language like C# (or even worse Ada) to keep your coding honest!

In fact, I think when building an UI, VB is better because hooking up the event handling is a little more forgiving than in C#. And in VB.NET its eaiser to manage the namespaces …

In any event, I think Visual Studio allows you to mix and match in the same solution anyway; so why not develop user interfaces in VB and backend processing in C# if you really have to? If your following your OOP principles properly, you ought to be separating out your presentation anyway.

It seems there are certainly more jobs available in C#, so right now I would advise anyone new to the industry to concentrate on becoming proficient with C#; the switch from C# to VB.NET should then be trivial.

There is nothing worse for a programmer’s career than to be stuck in a niche language, so really I’m surprised that people get so hung up on their favourite language. After all most modern languages all offer the same features: modules/functions, variables, if statements, loops etc.

Speaking as a professional programmer of over 21 years, code is just code. Its all the same regardless of the language because the really important part is how the problem is solved.