Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Desktop Developer

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

Search

XML Feeds

Google Ads

« VB.Net and C# - the difference in OO syntax part 2VB.Net: drawing a string on a panel that is created at runtime. »
comments
Rate Post:
submit to reddit Digg!FacebookDotnetkicks

I am a VB.Net developer that writes C# code. I use C# for writing my test projects since Rhino mocks likes C# a lot better then it does VB.Net and we can all blame it on the bad lambda implementation that VB.Net 9.0 has. Lucky for us, this will improve in VB.Net 10.0.

But I am writing this series of posts about the difference between C# and VB.Net because I am preparing for a promotion exam. The only way to get a promotion when working for the government is via an exam. And those exams are organized by some people in a land far, far away ;-). For this exam I had the choice between three languages Java, C# and ASP.Net. First question that comes to mind is “Since when is ASP.Net a language?” and then “Oh well". So I had to choose between C# and Java. Since I don’t use the Java framework as much as I used to, I chose C#.

The exam is in two parts. The first part was back in April and I passed but I learned that my C# isn’t good enough. You see the test is paper and pen only, no IDE help in sight. So knowing the syntax becomes more important and knowing the syntax like the back of my hand is important for me. Enough blah-blah, on to the important stuff.

So to make things easier for me, I will write this series of posts, just for myself. But if it helps someone then that is an added bonus. So here goes part one. The simple things.

If you want to learn the beginnings of C# then here are some sites you could use.

Prerequisites

First we create a solution with 1 C# consoleapplication, 2 C# class libraries, 1 VB.Net consoleapplication and 2 class libraries.

The solution should look like this after you have done.

Classes

First thing to do is see how a standard class is made in both languages.

  1. Public Class Class1
  2.  
  3. End Class
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace C_Class_Library_2
  7. {
  8.     public class Class1
  9.     {
  10.     }
  11. }

A big difference from the start. To begin with, Public in VB.Net and public in C#: they both do the same so we won’t really dawdle too much on them.

Then we say that C# uses a namespace by default, in this case this is the project name because that has the same namespace as the projectname (you can change it and have them different if you really like).

Then we have the using statements. VB.Net doesn’t seem to have the corresponding Imports statements, this happens to have a simple explanation. Because VB.Net does have them, it just has project/assembly level imports for us, so we don’t have to type everything in every class.

I couldn’t find this for C# so I guess it isn’t there.

I don’t want to make this post too long, I know you all have a short attention span. So I will continue in part two. See you tomorrow.

About the Author

User bio imageChristiaan is a forensic technician who programs on the side, although my function description says that I do IT-things for 90% of the time . I'm an avid VB.NET fan and I use lots of the ALT.Net techniques, like unit-testing, nhibernate, logging, IoC, ...
Social SitingsTwitterLinkedInHomePageLTD RSS Feed
1033 views
beginner, c#, vb.net
submit to reddit Digg!FacebookDotnetkicks

Comments and Feedback

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)