> What you want is covariant return types that is overridden methods can
> return subclasses from the original return type but this is not
> supported in
> C# yet but I really hope it will in the future.
That wouldn't change anything. GetProcessById is a static method
implemented by the Process class and it always creates a Process object.
With or without covariant return types, you cannot transform this into a
MyProcess object.
The best I can think of would be to wrap the Process instance in you
MyProcess object, i.e.
MyProcess p = new MyProcess(Process.GetProcessById(processID));
Fabian
cody - 09 Feb 2005 11:59 GMT
> > What you want is covariant return types that is overridden methods can
> > return subclasses from the original return type but this is not
[quoted text clipped - 10 lines]
>
> MyProcess p = new MyProcess(Process.GetProcessById(processID));
Oh I misunderstood, yes in case of a static method covariance won't help but
you can define a new method with the same name as the inherited class
public static new MyProcess GetProcessById(int pid)
{
return new MyProcess (Process.GetProcessById(pid));
}