C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Difference between C# and VB.NET


Posted Date: 09 Oct 2009    Resource Type: Articles    Category: .NET Framework
Author: Virendra DugarMember Level: Bronze    
Rating: 1 out of 5Points: 15



Introduction



This question is almost asked in every interview, if you have worked with both the language. There are syntax difference, keyword difference in both the language. But the interviewer is not looking for such answers. One need to explain the functional difference between both the language.

Here are some key difference in C# and VB.NET other than syntax difference.

Differences


1. In C#, using keyword is used to release unmanaged resources. (Not available in VB.NET)

2. Optional parameter is supported in VB.NET. (Not available in C#).

3. Structure and unstructured error handling (On Error GoTo) is supported in VB.NET. (Unstructured error handling is not supported in C#).

4. Event gets binded automatically in VB.Net.

5. VB.NET is not case sensitive.

6. Shadowing: - This is a VB.Net Concept by which you can provide a new implementation for the base class member without overriding the member. You can shadow a base class member in the derived class by using the keyword "Shadows". The method signature, access level and return type of the shadowed member can be completely different than the base class member.

Hiding: - This is a C# Concept by which you can provide a new implementation for the base class member without overriding the member. You can hide a base class member in the derived class by using the keyword "new". The method signature, access level and return type of the hidden member has to be same as the base class member.

Comparing the two:-

1) The access level, signature and the return type can only be changed when you are shadowing with VB.NET. Hiding and overriding demands these parameters as same.

2) The difference lies when you call the derived class object with a base class variable. In class of overriding although you assign a derived class object to base class variable it will call the derived class function. In case of shadowing or hiding the base class function will be called.

7. Visual Basic .NET can also force parameters to be passed by value, regardless of how they are declared, by enclosing the parameters in extra parentheses. There is no way to achieve this thing in C#.
For Example:

Dim y As Integer = 5
Dim z As Integer
z = Add(y) //This will set both Y and Z to 6.
z = Add((y)) //This will set Z to 6 but Value of Y will not be change, as we have included extra parenthese while calling.


The Add function:

Public Function Add(ByRef x As Integer) As Integer
x = x + 1
Return x
End Function


Conclusion


I know this is not a complete list, so if you know any other difference kindly post your comments.


Enjoy..


Attachments

  • Difference between C# and VB.NET ()


  • Responses

    Author: Khan    12 Oct 2009Member Level: Silver   Points : 0
    Nice article. Have used the simple understandable english.




    Author: laxmi    13 Oct 2009Member Level: Silver   Points : 0
    Good Article. Keep posting.


    Author: Varma Suresh    27 Oct 2009Member Level: Gold   Points : 0
    good article,Keep contributing


    Author: Thamil Selvan J.    27 Oct 2009Member Level: Silver   Points : 1
    Very useful article for beginners as well as senior also. Keep posting helpful article like this.




    Author: Varma Suresh    27 Oct 2009Member Level: Gold   Points : 0
    good article,Keep contributing


    Author: Virendra Dugar    27 Oct 2009Member Level: Bronze   Points : 0
    Thank you All..


    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Sign In to add tags.
    VB.NET  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Simple Way to Creating Application Domain
    Previous Resource: Drag Drop in window form using c#.net
    Return to Discussion Resource Index
    Post New Resource
    Category: .NET Framework


    Post resources and earn money!
     
    More Resources



    dotNet Slackers

    About Us    Contact Us    Privacy Policy    Terms Of Use