C
Chun Wang
1. When writing genric classes or methods, can I use
specifc type (instead of generic type) as type parameter?
For example:
pulic class MyStack<T, int>
{
.....
}
Here maybe I want to establish a upper limit of the stack.
2. Does the implemention support specialization? (I mean
something like C++ template specialization) This is an
extremely useful language feature in C++ template.
for example:
public class MyStack<T>
{
....
}
public class MyStack<string>
{
....
}
This is not a good sample, but it explains what I paray
for.
3. For operator as and is, does it support genric classes?
For example:
class MyNode<T>
{
....
}
class MyList<T>
{
....
public void MyMethod(T t)
{
if(t is MyNode<T>)
{
MyNode<T> obj = t as MyNode<T>;
}
....
}
Again this is a bad sample. But the question is, am I
allowed to write code like this?
4. constraint is an elegant solution for some long-time
issues for C++ template. But I think it will be very
tedious to repeat every constraints at basecalss level
when developing subcalsses. The compiler sure can infer
all these constraints at baseclass level. Is there any
technical difficulty or sound reason for compiler not to
do it?
5. It's thrilling to learn that Microsoft will provide
a .NET version of STL. But can't find more information
about it. What is expected to this .NET version STL?
What's missing and What's improved?
6. Can I overload operators for generic classes? If I can,
can I have extra genric type parameter for such operators?
specifc type (instead of generic type) as type parameter?
For example:
pulic class MyStack<T, int>
{
.....
}
Here maybe I want to establish a upper limit of the stack.
2. Does the implemention support specialization? (I mean
something like C++ template specialization) This is an
extremely useful language feature in C++ template.
for example:
public class MyStack<T>
{
....
}
public class MyStack<string>
{
....
}
This is not a good sample, but it explains what I paray
for.
3. For operator as and is, does it support genric classes?
For example:
class MyNode<T>
{
....
}
class MyList<T>
{
....
public void MyMethod(T t)
{
if(t is MyNode<T>)
{
MyNode<T> obj = t as MyNode<T>;
}
....
}
Again this is a bad sample. But the question is, am I
allowed to write code like this?
4. constraint is an elegant solution for some long-time
issues for C++ template. But I think it will be very
tedious to repeat every constraints at basecalss level
when developing subcalsses. The compiler sure can infer
all these constraints at baseclass level. Is there any
technical difficulty or sound reason for compiler not to
do it?
5. It's thrilling to learn that Microsoft will provide
a .NET version of STL. But can't find more information
about it. What is expected to this .NET version STL?
What's missing and What's improved?
6. Can I overload operators for generic classes? If I can,
can I have extra genric type parameter for such operators?