vb.net or C#?

D

Dan

Hi,

i develop webapplications with asp.net and vb.net. Is there any good reason
why i should switch to (and learning) C#?

Thanks for the pro's and contra's.
Dan
 
D

Dan

Thanks, i start right now with C# ...

Mark Rae said:
Technically speaking, no. C# supports unsafe code aka pointers, but that's
about the only difference...

Commercially speaking, learning C# will (in theory anyway) make you twice
as marketable...

Since you work with ASP.NET, you will almost certainly have plenty of
experience with JavaScript, so you will not find the C# syntax too
difficult to grasp..
 
S

Stan

Hi,

i develop webapplications with asp.net and vb.net. Is there any good reason
why i should switch to (and learning) C#?

Thanks for the pro's and contra's.
Dan

Hi Dan

I started working in VB.NET for web apps but have since changed over
to C#

I prefer it but have never been able to pin down the reason(s). It
might be the use of symbols such as { } for statement blocks rather
than key words like if, end if etc Without the code assistant this
would make a lot of difference, but as it is the VS code editor saves
a lot of typing.

One thing you may find strange at first are the different rules for
assignment compatibility. VB allows strings and numbers to be used
almost interchangeably but C# is more fussy and requires explicit
conversion. Use the Parse() function for strings to numbers and dates.
Also remember that Session[] and DataRow/DataRowView indexes return
objects that require type casting in C#
You will also find that list elements have values that are strings and
unlike VB will cannot be aigned to number variables without
conversion.

Good luck
 
J

Jonathan Wood

For the most part, they are exactly the same language but with slightly
different syntax. With few exceptions, it comes down to your taste in syntax
and what language potential employers are deciding to use.
 
S

sloan

If

Option Strict On
Option Explicit On

is set in vb.net files (or there are project level settings)

Then vb.net works almost like c#.

But there is no way to "turn it off" in C#, which I prefer.



Stan said:
Hi,

i develop webapplications with asp.net and vb.net. Is there any good
reason
why i should switch to (and learning) C#?

Thanks for the pro's and contra's.
Dan

Hi Dan

I started working in VB.NET for web apps but have since changed over
to C#

I prefer it but have never been able to pin down the reason(s). It
might be the use of symbols such as { } for statement blocks rather
than key words like if, end if etc Without the code assistant this
would make a lot of difference, but as it is the VS code editor saves
a lot of typing.

One thing you may find strange at first are the different rules for
assignment compatibility. VB allows strings and numbers to be used
almost interchangeably but C# is more fussy and requires explicit
conversion. Use the Parse() function for strings to numbers and dates.
Also remember that Session[] and DataRow/DataRowView indexes return
objects that require type casting in C#
You will also find that list elements have values that are strings and
unlike VB will cannot be aigned to number variables without
conversion.

Good luck
 
C

Cowboy \(Gregory A. Beamer\)

If you started with VB.NET, probably not. If you started with VB and moved
to VB.NET, you are probably using a lot of training wheels. The easiest way
to tell is whether or not you are using the Microsoft.VisualBasic
namespaces, esp. .Compatibility. In this case, learning C# makes you more
likely to learn the Framework and get rid of the training wheels.

As far as other reasons. I find there are more C# jobs than VB.NET. If this
is not true in your area, then you need not worry, other than the suggestion
above.
 
C

Cowboy \(Gregory A. Beamer\)

I would disagree that they are "exactly the same language but with slightly
different syntax". Language wise, there are loads of difference. But, if you
are using the Framework properly, they are fairly identical. One uses [],
the other () and you have to add semi-colons. :)
 
S

Scott M.

One thing you may find strange at first are the different rules for
assignment compatibility. VB allows strings and numbers to be used
almost interchangeably but C# is more fussy and requires explicit
conversion.

The first thing a VB .NET developer should do is turn on Option Strict for
all their projects. Once that is done, VB .NET is a type-safe language,
just as C# is and the situation you described above will not be allowed.

-Scott
 
J

Jonathan Wood

Cowboy,
I would disagree that they are "exactly the same language but with slightly
different syntax". Language wise, there are loads of difference. But, if
you are using the Framework properly, they are fairly identical. One uses
[], the other () and you have to add semi-colons. :)

Heh, well I did say "for the most part." But, really, I find when I'm
reading books that show code samples in both VB.NET and C#, I find almost no
reason to look at the sample that uses the code I happen to be using.
Primarily for the reason you suggested: most of the language consists of
framework calls. Just a different syntax.
 
R

Riki

Dan said:
Hi,

i develop webapplications with asp.net and vb.net. Is there any good
reason why i should switch to (and learning) C#?

Thanks for the pro's and contra's.
Dan

In addition to what is already said, I like the "My" namespace a lot in
VB.NET.
It is missing in C#.
 
G

Göran Andersson

Dan said:
Hi,

i develop webapplications with asp.net and vb.net. Is there any good reason
why i should switch to (and learning) C#?

Thanks for the pro's and contra's.
Dan

Regardless if you switch language or not, you will get a better
understanding of programming in general by learning C# too.

C# and VB.NET compile into pretty much the same IL code, so learning how
C# works will also make you understand better what your VB.NET code does.
 
M

Marc

Dan said:
i develop webapplications with asp.net and vb.net. Is there any good
reason why i should switch to (and learning) C#?

No. But let me give you my opinion.

For making applications, it should not matter that much, it's not that one
is that much better then the other.

For job opportunities, I think you should do some C#.

Then another thing is, how much trouble would you have writing in another
language? The past two years I've used C++, Delphi, Java, VB.NET, C#,
ASP.NET, JSP and Javascript in different projects. If I work in one language
for two weeks I am used to it. Even though I have more experience in C++ for
example, now I am programming in Delphi, and if I now have to write C++ code
I put 'then' afther my if statements. Just like on holiday, after speaking
Spanish for two weeks, I forget my German en English, while I am Dutch.

Hence the writing EndIf instead of }, that's not really the main problem in
writing ASP.NET programs, that what I think. One could change from VB to C#
in less then a month. Learning the framework possibilities would cost you a
year at least.
 
M

Marc

Göran Andersson said:
C# and VB.NET compile into pretty much the same IL code, so learning how
C# works will also make you understand better what your VB.NET code does.

I don't agree. It's mostly different syntax words for the same. So if you
want to understand syntax, and OOP for example, study OOP in a language you
already know is better then learning different syntax details of another
language. You could better study how compilers work, how OOP works,
independant of the exact language. If you understand that, it's relative
less difficult to work in another language.
 
M

Marc

So would I.

But I would not. :)

Nowadays with an IDE that already gives you a warning something is not
according to the syntax of a certain language before you press compile, the
reds curly lines, it's quite easy.
 
M

Marc

Mark Rae said:
Please explain how C# and VB.NET are "for the most part exactly the same
language but with slightly different syntax"...

Both are object oriented computer languages compiling to the same
intermediate language and working on the same framework libs. Anyway it
would also say that for Java and C#. Here the syntax is even more simular,
but then you use another framework. You do not have to know all the details
of a language to write code in it. Ok, it makes you a bit faster if you do,
that is true. You paste and copy code less. You use codesnippets less.

The IDE, the framework, the libs, the domain you write code for, client
server programming in general, that's far more important then the language
as such.
 
G

Göran Andersson

Marc said:
I don't agree. It's mostly different syntax words for the same. So if you
want to understand syntax, and OOP for example, study OOP in a language you
already know is better then learning different syntax details of another
language.

Have you considered the fact that many elements in the VB syntax is
intended to hide what's actually going on? It doesn't matter how long
you stare at the code, you still can't see what's not there. ;)
You could better study how compilers work, how OOP works,
independant of the exact language. If you understand that, it's relative
less difficult to work in another language.

Agreed, you can gain the same knowledge by studying these aspecs
independently of any language. However, it's harder to find that kind of
material, as most examples are written to actually be used in a specific
language.
 
M

Marc

Göran Andersson said:
Have you considered the fact that many elements in the VB syntax is
intended to hide what's actually going on?

Mmmm, yes that's true. In that case C# is better.
 
B

Bill McCarthy

Göran Andersson said:
Have you considered the fact that many elements in the VB syntax is
intended to hide what's actually going on?

Isn't that the purpose of a higher level language: to abstract the details
away ? Or do you consider Using blocks or iterators or anonymous delegates
or captures all bad ?
 
C

Cowboy \(Gregory A. Beamer\)

Marc said:
Nowadays with an IDE that already gives you a warning something is not
according to the syntax of a certain language before you press compile,
the reds curly lines, it's quite easy.

Still does not make things the same language. While the IDE may warn you
that things are awry, it will not tell you how to correct your code. If all
that is wrong is curly braces or semi-colons, you are tracking. But there
are other languages differences that do matter.

A quick example:

builder.Append("\r\n");

builder.Append(vbCrLf)

Now, you don't have to use vbCrLf, of course, but most vb devs would, as it
is familiar. How about this:

string connString = "";
SqlConnection conn = new SqlConnection(connString);

Dim connString as String = ""
Dim conn As new SqlConnection(connString)

Functionally equivalent, but knowing the syntax is wrong (backwards?) does
not help you write it. Or how about this:

using(SqlConnection conn = new SqlConnection(connString))
{
conn.Open();
//etc.
}

Dim conn As New SqlConnection(connString)

Try
conn.Open()
Finally
conn.Dispose()
End Try

With no using in .NET 2.0, you are forced to use a Try ... Finally to
accomplish the same thing. No amount of red squigglies will give you the
knowledge to do that.

It gets even more difficult to translate when you start using Generics, as
C# using a much simpler syntax. I could also go into a list of differences
in string handling, LINQ, etc.

As I stated, I agree that they are functionally equivalent, at least
overall, but they are not the same language sans curly braces.
 
C

Cowboy \(Gregory A. Beamer\)

Jonathan Wood said:
Heh, well I did say "for the most part." But, really, I find when I'm
reading books that show code samples in both VB.NET and C#, I find almost
no reason to look at the sample that uses the code I happen to be using.
Primarily for the reason you suggested: most of the language consists of
framework calls. Just a different syntax.

As long as the developer uses the Framework, it is largely true. A lot of VB
developers use the training wheels (VB Compatibility namespace), so all bets
are off. I listed some other differences in response to Marc. ;->

When I am forced to use VB, I often find it prudent to code in C#, compile
and then use Reflector to find the equivalent VB syntax. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top