Question About Future C# Syntax (Generics)

  • Thread starter Thread starter Matthew W. Jackson
  • Start date Start date
M

Matthew W. Jackson

I had a question about the "using" statement and Generics in the next
version of C#, and I was directed to this newsgroup. My question is: Will
the following syntax be valid?


using Int32ArrayList = System.GCollections.ArrayList<Int32>;
....
Int32ArrayList myArrayList = new Int32ArrayList();


I (along with many others) use a similar method in C++ with typedefs, and to
me it really makes STL code a lot cleaner. I see no reason why this should
not be possible in Whidbey C#, but I may be missing something. This is of
course a trivial example, but in cases where there are several template
parameters (and even moreso, nesting), it really helps.

I don't have time to install Rotor and Gyro to find out if it works in that
environment, so I thought I'd ask here first.

Thanks in advance,

Matthew W. Jackson
 
Matthew W. Jackson said:
I had a question about the "using" statement and Generics in the next
version of C#, and I was directed to this newsgroup. My question is: Will
the following syntax be valid?

using Int32ArrayList = System.GCollections.ArrayList<Int32>;
...
Int32ArrayList myArrayList = new Int32ArrayList();

I heard that they are considering some using alias directives support for
generics for Whidbey.

Jürgen Beck
MCSD.NET, MCDBA, MCT
www.Juergen-Beck.de
 
I'm kinda hoping for some type of inline ILASM block. It would probably be
easiest just to allow one to write the whole function in il, or none of it.
This is kinda what I was thinking:

class Test
{
void Main() {
Console.WriteLine(Add(5, 6));
}

// ilasm function
int ilasm Add(int a, int b) {
ldarg.0 // push a on stack
ldarg.1 // push b on stack
add // add 2 args
ret // return int on the stack
}

/*
C# code for the ilasm is here:
int Add(int a, int b) {
return a + b;
}
*/

}




Chris
 
The answer is "yes", you will be able to do that, but note that you do not
get real typedefs out of this. Typedefs define specific types, while aliases
are just shortcuts.
 
Back
Top