[Mono-list] RE: Platforms Mono will support?

Jonathan Pryor jonpryor@vt.edu
15 Sep 2002 10:48:34 -0400


C# has equivalents to some of the VB differences you mention below.

More comments inline.

On Sat, 2002-09-14 at 17:35, Chris Daly wrote:
<snip/>

> But here's something you can do in VB but not in C#:
> 
> Imports System.Collections.ArrayList
> 
> In other words, your using/imports names a type instead of a namespace
> (using aliases are pretty much the same for VB and C#).

C# allows type aliasing, which can give you equivalent functionality:

	using ArrayList = System.Collections.ArrayList;

You can use any name after the `using':

	using MyListType = System.Collections.ArrayList;

> - Parameterized properties.  Here's another thing you can do in VB but not
> C#.  Properties can take parameters, so you can have code like this:
> 
> x = myFoo.Item["x"]
> myFoo.Item["x"] = y
> 
> Where Item is a property defined on the Foo class.  The closest thing to
> this in C# is indexers.  What C# calls an indexer is called the "default
> property" in VB.

This can be "faked" in C# by having a property whose type implements an
indexer:

	class Foo {
		IDictionary Item {
			get {/*...*/}
		}

		public static void Demo () {
			Foo myFoo = new Foo ();
			object o = myFoo.Item["x"];
		}
	}

I'm not familiar enough with VB to know how different the VB semantics
would be compared to the above, however.

Your other points are sensible.  VB.NET and C# are different, and
they're likely to diverge more in the future.

<snip/>

> Chris

 - Jon