Monday, January 26, 2004

.NET plumbing bitch

Why must I write

MyClass[] anArrayOfMyClass = ArrayList.ToArray(new MyClass().GetType());

???

It would be so much easier if classes knew about themselves - for instance, something like:

MyClass[] anArrayOfMyClass = ArrayList.ToArray(MyClass.type);

-- followup a few days later
OK - it turns out that C# has a keyword for this. I can say:
MyClass[] anArrayOfMyClass = ArrayList.ToArray(typeof(MyClass));
which is cleaner, but still feels - I don't know - wrong somehow.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home