473,791 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Difference between C# and VB.NET

Hi Guys,

It might seem to be a very easy question, but i am very much eager to
know some good technical difference between C# and VB.NET.

Are there anything that i can do in one language and cannot in other?
And finally why C# seems to be a sort of standard in industry?

Regards,
Raj Dhrolia.
Nov 15 '05 #1
11 3611
Yes, a good question.

For example are there differences in

- implicit/explicit conversions
- user-defined operators

?

i just haven't look at vb so maybe a quick guide could be provided by
someone
to help us avoid digging in vb specification?
Nov 15 '05 #2
> Are there anything that i can do in one language and cannot in other?

For example, in VB .NET a single class method can implement several
interface methods. This trick, as fas as I know, is not possible in C#. In
fact, most of the differences between the languages are subtleties like this
one. I think there is no fundamental task you can do in one language and
cannot in the other.
And finally why C# seems to be a sort of standard in industry?
I think because it has been initially designed for .NET while VB.NET is
rather an improvement to VB6.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Raj Dhrolia" <ra********@hot mail.com> wrote in message
news:uu******** ******@TK2MSFTN GP09.phx.gbl... Hi Guys,

It might seem to be a very easy question, but i am very much eager to
know some good technical difference between C# and VB.NET.

Are there anything that i can do in one language and cannot in other?
And finally why C# seems to be a sort of standard in industry?

Regards,
Raj Dhrolia.


Nov 15 '05 #3
Dmitriy Lapshin [C# / .NET MVP] wrote:
For example, in VB .NET a single class method can implement several
interface methods. This trick, as fas as I know, is not possible in
C#.


I don't understand this statement. C# classes can implement more than
one interface and the methods contained therein so obviously you're
talking about something else.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #4
I mean the following construct:

In VB .NET:

Private Sub DoSomething() Implements IFirst.DoSometh ing, ISecond.DoSomet hing

In C# we can only:

void IFirst.DoSometh ing()
void ISecond.DoSomet hing()

if we do not want to expose the DoSomething() method as a part of the public
class interface.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Frank Oquendo" <fr****@acadxpi n.com> wrote in message
news:e7******** ******@TK2MSFTN GP11.phx.gbl...
Dmitriy Lapshin [C# / .NET MVP] wrote:
For example, in VB .NET a single class method can implement several
interface methods. This trick, as fas as I know, is not possible in
C#.


I don't understand this statement. C# classes can implement more than
one interface and the methods contained therein so obviously you're
talking about something else.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)


Nov 15 '05 #5
I would add Indexers. For example when you do this

Row("FieldName" )="jajaja"
this is the .ITEM property of DataRow class. And this property is indexed by
a "Key". Indexers are available only in C#
In VB you should make a GetByKey method.

And in C# there is no
with object
...
end with

"Alexander Nenashev" <ne******@hotbo x.ru> escribió en el mensaje
news:#T******** *****@TK2MSFTNG P11.phx.gbl...
Yes, a good question.

For example are there differences in

- implicit/explicit conversions
- user-defined operators

?

i just haven't look at vb so maybe a quick guide could be provided by
someone
to help us avoid digging in vb specification?

Nov 15 '05 #6
You certainly can do indexers in VB. Have you tried the Default keyword? In
fact, you can have named indexers, since all properties can take parameters.
While I wouldn't call this a "limitation " of C#, it is true that VB does
MORE than C# in this respect.

Matthew W. Jackson

"Osvaldo Bisignano" <va************ *@yahoo.com.ar> wrote in message
news:Oh******** ******@TK2MSFTN GP09.phx.gbl...
I would add Indexers. For example when you do this

Row("FieldName" )="jajaja"
this is the .ITEM property of DataRow class. And this property is indexed by a "Key". Indexers are available only in C#
In VB you should make a GetByKey method.

And in C# there is no
with object
...
end with

"Alexander Nenashev" <ne******@hotbo x.ru> escribió en el mensaje
news:#T******** *****@TK2MSFTNG P11.phx.gbl...
Yes, a good question.

For example are there differences in

- implicit/explicit conversions
- user-defined operators

?

i just haven't look at vb so maybe a quick guide could be provided by
someone
to help us avoid digging in vb specification?


Nov 15 '05 #7
Actaully, VB supports Properties with arguments, which is in fact, far more
flexible than Indexers - because you can have more than one per class for
starters.
To create a simple Indexer, just use the VB Default keyword on the property
and have at least one property argument.

-Rob Teixeira [MVP]

"Osvaldo Bisignano" <va************ *@yahoo.com.ar> wrote in message
news:Oh******** ******@TK2MSFTN GP09.phx.gbl...
I would add Indexers. For example when you do this

Row("FieldName" )="jajaja"
this is the .ITEM property of DataRow class. And this property is indexed by a "Key". Indexers are available only in C#
In VB you should make a GetByKey method.

And in C# there is no
with object
...
end with

"Alexander Nenashev" <ne******@hotbo x.ru> escribió en el mensaje
news:#T******** *****@TK2MSFTNG P11.phx.gbl...
Yes, a good question.

For example are there differences in

- implicit/explicit conversions
- user-defined operators

?

i just haven't look at vb so maybe a quick guide could be provided by
someone
to help us avoid digging in vb specification?


Nov 15 '05 #8

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.c om> wrote
in message news:uF******** ******@tk2msftn gp13.phx.gbl...
Are there anything that i can do in one language and cannot in other?

For example, in VB .NET a single class method can implement several
interface methods. This trick, as fas as I know, is not possible in C#. In
fact, most of the differences between the languages are subtleties like this one. I think there is no fundamental task you can do in one language and
cannot in the other.


There are a few things each can do that the other can't (and I suppose you
can argue about how "fundamenta l" these things are). At the moment, VB can't
overload operators and can't use unsigned types natively (it can use the
primitive unitXX classes, for example, but not directly like their signed
cousins) - this one in particular is fairly odd, considering that VB
recently introduced shift operators. Also, VB can't directly manipulate
pointers without the help of classes in the system.runtime. interop namespace
and GC handles to pinned references (although to be fair, C# also requires
pinned references, though the syntax is slightly different).

At any rate, with the next version of VS, VB will be able to handle all
these features except the direct pointer manipulation AFAICT. Do note
however, that direct pointer manipulation is not considered part of the core
CLI, and must be marked as Unsafe code. However, VB can still manipulate
pointers, so in this case, it's not as if it can't be done, it will just be
different.
And finally why C# seems to be a sort of standard in industry?


I think because it has been initially designed for .NET while VB.NET is
rather an improvement to VB6.


Actually, if memory serves, C# was going to be an independant project, and
then got merged/morphed into the Common Language specs/framework as well.
However, as you mentioned, unlike VB, C# has no clear and direct
predicessor. It's another "C-like" language.

I'm not sure what the original poster means by industry standard. I'm
willing to wager there is far more code in VB than C# at the moment -
especially if you concider older VB/VBScript/ASP code and migrations
thereof. Fundamentally, if you are using .NET, you writing IL code. The
syntax that gets you to the IL (whether it's VB, C#, FORTRAN, or even COBOL)
is in essance slightly less relevant. So basically, instead of doing what
Sun did with Java - which was to create ONE master language everyone had to
learn - the .NET team gave programmers a choice of syntax. If the programmer
is more familiar with VB, then VB.NET will be his best choice to enter the
..NET world, while other programmers who are more familiar with Java/C/C++
will find it easier to use C#. As always, I recommend that everyone learn
both - they aren't entirely different, and the hardest part is learning the
framework (which they both share). This will make you a far more valuable
resource, and doesn't take much effort.

One thing to note in addition is that C# has been submitted to international
standards - which means that others can write their own implementation of C#
based on the official specification. VB.NET, on the other hand, is
proprietary property of MS. But that's about the only "standard" that you
can concretely quantify.

-Rob Teixeira [MVP]
Nov 15 '05 #9
<"Rob Teixeira [MVP]" <RobTeixeira@@m sn.com>> wrote:
Actaully, VB supports Properties with arguments, which is in fact, far more
flexible than Indexers - because you can have more than one per class for
starters.


You can have more than one indexer per class in C#. You just can't have
more than one indexer with the same parameters signature.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
7112
by: yensao | last post by:
Hi, I have a hard time to understand difference and similarities between Relational database model and the Object-Oriented model. Can somebody help me with this? Thank you in advance. Yensao
21
3022
by: b83503104 | last post by:
Hi, Can someone tell me the difference between single quote and double quote? Thanks
26
4422
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
21
2853
by: Rich | last post by:
I was considering C# for developing a scientific application, but I have noticed a ~30% difference between VC++ .NET and C# on the same machine, under identical conditions: double a = 0,b = 0, c = 0, d = 0, e = 0; for(int n = 0; n != 6000000; n++) { a = n % 5 *2 / 3 - 4 + 6 / 3 - n + n * 2; b = n * 2.3 - 1 *2 / 3 - 4 + 6 / 3 - n + n * 2; c = n * 3 / 3.5 *2 / 3 - 4 + 6 / 3 - n + n * 2;
4
15759
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow which calculated the difference in years and days between two dates, and takes leap years into account? I'm calculating the difference in the usual way, i.e....
3
4163
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second column I have to show difference between Currenttime and date from ItemReceived. How can I do that.
12
2717
by: Petronius | last post by:
Hallo, does anyone have an idea how to implement difference lists in Javascript? Thanks allot in advance
5
3489
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference: 1 day, 1hour
9
2681
by: viki1967 | last post by:
Hi all! This new forum its great! :) Congratulations !!! My answer: why this my code not working? Nothing error but not work the difference.... : <html>
11
12126
by: cmb3587 | last post by:
I have two arrays and I'm trying to create a 3rd array that is the difference between the two arrays Ex: arrayA: 3 5 8 9 arrayB: 3 4 6 9 difference of A-B: 5 8 however, my code is just returning me an array of 0's
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.