I gave that a try and it looks like it would work.
However, in my case, my BaseClass is used in a Generic List Base Class that
has a generic parameter.  So the combination of generic parameters does not
work properly.

Since this is true:

class A: BaseClass{
...
}

class B:BaseClass{
...
}

class BaseCollection<T>:List<T>{
}

class ACollection:BaseCollection<A>{
...
}

class BCollection:BaseCollection<B>{
...
}

In this example, neither ACollection nor BCollection can be cast to a
BaseCollection<BaseClass>.
Since the idea behind generics that that BaseCollection<A> is not the same
as BaseCollection<B>.

Thanks,
Mike






On 9/6/06, Marc Brooks <[EMAIL PROTECTED]> wrote:

> public class BaseClass{
>  public string Serialize(){
>    //This will not work
>    return Serialization.GetSerializedXml<typeof(this)>(this);
>  }
> }

public class BaseClass<T>{
public string Serialize(){
   return Serialization.GetSerializedXml<T>(this);
}
}

public DerivedClass : BaseClass<DerivedClass>
{
  // stuff
}


--
"We do not have the luxury of making that risky assumption that people
will not be affected by the potential change. I know this can be
frustrating for you as it is for us. Thanks for your understanding in
this matter.." --Some misguided soul at Microsoft

Marc C. Brooks
http://musingmarc.blogspot.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com


===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to