1

I'd like to be able to do this:

class IntMyClass : MyClass<int> { }
class StringMyClass : MyClass<string> { }
class FloatFloatMyClass : MyClass<float, float> { }
class Container<T, U> where T : MyClass<U> { 
    List<U> List;

    Set(){
       List.First().Value1 = List.Last().Value1;    
    }
}

class Container<T, U, V> where T : MyClass<U, V> { 
    List<U> List;
    List<V> List2;

    Set()
       List.First().Value1 = List.Last().Value1;    
       List.First().Value2 = List.Last().Value2;    
    }
}

public class SomeOtherClass{
    Container<IntMyClass> IntContainer;
    Container<FloatFloatMyClass> FloatFloatContainer;
}

However, the last part:

public class SomeOtherClass{
    Container<IntMyClass> IntContainer;
    Container<FloatFloatMyClass> FloatFloatContainer;
}

Gives an error for incorrect number of parameters. Is it possible for C# to infer that the 2nd parameter should be an int based on the IntTuple class?

helaj80024
  • 33
  • 3

0 Answers0