Go Back

Some .net Trivia c# vs VB

So Chris called me out of the blue and asked me an interesting question...

"Why is it that in VB.Net you can write a virtual method without declaring a protection level, but in c# you can?"

Upon further inspection, the simple fact is that when you write this:

Sub Foo()

End Sub

you're saying the same thing as:

Public Sub Foo()

End Sub

Where-as in c# when you do void Foo(){} it's equivalent to

private void Foo() {}

 

Our discussion then turned to another interesting attribute of c# and that was it's lack of ability to pass properties by reference in methods.

For example if you had:

public object Foo

{

get{/*implementation */}

set{/*implementation */}

}

you can't pass that into a method that looks like this:

public void Action(ref object param){}

 

I won't go into the details but a nice explanation of it can be found here

 

Facebook DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Furl it!

Post a comment!
  1. Formatting options