Failwyn wrote:Ultimately, I don't want there to be anything different between the classes other than the ability to use a simplified signature.
The answer depends on what you mean by that statement.
The derived class is the only solution I can see. But the types would not be exactly the same:
MyClass<Guid> a = new MyClass<Guid>();
MyClass<Guid, Guid, Guid, Guid> b = a;
MyClass<Guid> c = b; And:
MyClass<Guid, Guid, Guid, Guid> a = new MyClass<Guid, Guid, Guid, Guid>();
MyClass<Guid> b = (MyClass<Guid>)a;
MyClass<Guid> c = a as MyClass<Guid>;
Within a single file, you could use a
using statement to create an alias for the type. But you can't use generic type parameters in the alias, so you'd need a different one for each set of type parameters you wanted to use:
using MyClassGuid = MyClass<Guid, Guid, Guid, Guid>;
MyClassGuid a = new MyClassGuid(); You'd also have to repeat the alias in each file where you needed to use it.
If it's constructing the objects you're worried about, then a factory method might help:
public static class MyClass
public static MyClass<T1, T2, T3, T4> Create<T1, T2, T3, T4>(T1 value1, T2 value2, T3 value3, T4 value4)
return new MyClass<T1, T2, T3, T4>(value1, value2, value3, value4);
public static MyClass<T1, T1, T1, T1> Create<T1>(T1 value)
return new MyClass<T1, T1, T1, T1>(value, value, value, value);
MyClass<Guid, Guid, Guid, Guid> a = MyClass.Create(Guid.New());
MyClass<string, int, decimal, DateTime> b = MyClass.Create("Hello", 42, 123.45M, DateTime.Today);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."