   [.net] Inheriting Methods and Boxing
  Okay what I want to do is rather complicated to explain. I think code will show things better.class BasePoint{ Vector3 Position;}class PointA: BasePoint{ int SomeInt;}class PointB: BasePoint{ float SomeFloat;}class PointListA{ List<PointA> PointsList; Vector3 GetSomething(){return PointsList[0].Position;}}class PointListB{  List<PointB> PointsList;}Essentially from this example. All I want to do is somehow copy the GetSomething Method to the BasePointListB class without copying since it only requires infromation from the base class.Any ideas?   
  Did you try using a generic extension method?   ;  I'm not quite sure how that would help...   ;  If "GetSomething()" is common between PointListA and PointListB, can't you add a base class that both of those inherit? Then either put PointsList in that base class, allowing you to implement GetSomething() in the base class directly, or use an abstract function.   ;  Ah I meant to add a base class for the PointList classes in the code. I'll update it. But the problem with putting the list of points in the PointListBase is PointA and PointB are different.I'm not sure what an abstract function is. I'll look it up in a sec.Update: Okay from what I've seen, wouldn't using an abstract function mean I have to copy the function anyway. I see no other way around this other than casting the list to the base class type.   ;  what's wrong with something like this?class BasePoint{ Vector3 Position;}class PointA: BasePoint{ int SomeInt;}class PointB: BasePoint{ float SomeFloat;}class PointList<PointType>    where PointType : BasePoint{ List<PointType> PointsList; Vector3 GetSomething(){return PointsList[0].Position;}}That way, you don't even need to separate classes to handle lists of PointA and PointB. Although, if you do need extra specialisation, you can still derive from PointListclass PointListA : PointList<PointA>{   // special PointA stuff here}class PointListB : PointList<PointB>{   // special PointB stuff here}HTH   ;  Wow that works perfectly, Thanks! When generic extention method was said my mind went a completely different way with it.   ;Quote:Original post by AntiGuyWow that works perfectly, Thanks! When generic extention method was said my mind went a completely different way with it.That's actually not a generic extension method. What SiCrane was suggesting* was something like thispublic static class PointListUtils{    public static Vector3 GetSomething(this List<PointType> self)   where PointType : BasePoint    {   return self[0].Position;    }}//used like thisList<PointA> points = new List<PointA>;Vector3 blah = points.GetSomething();That would also work.*at least I think that's what he was suggesting. I'm hesitant to put virtual words in his mouth [grin]   ;  Yup, close enough. :)   