Click here to Skip to main content
14,430,533 members
   

C#

 
AnswerRe: How do I set a breakpoint in an attached process in visual studio? Pin
ZurdoDev4-Apr-19 10:20
mveZurdoDev4-Apr-19 10:20 
GeneralRe: How do I set a breakpoint in an attached process in visual studio? Pin
Xarzu5-Apr-19 5:22
MemberXarzu5-Apr-19 5:22 
AnswerRe: How do I set a breakpoint in an attached process in visual studio? Pin
Dave Kreskowiak4-Apr-19 10:24
mveDave Kreskowiak4-Apr-19 10:24 
GeneralRe: How do I set a breakpoint in an attached process in visual studio? Pin
Xarzu5-Apr-19 5:22
MemberXarzu5-Apr-19 5:22 
QuestionSimplify usage of a complex generic class for convenience Pin
Failwyn4-Apr-19 6:02
MemberFailwyn4-Apr-19 6:02 
AnswerRe: Simplify usage of a complex generic class for convenience Pin
Gerry Schmitz4-Apr-19 6:10
mveGerry Schmitz4-Apr-19 6:10 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff5-Apr-19 22:00
mveBillWoodruff5-Apr-19 22:00 
AnswerRe: Simplify usage of a complex generic class for convenience Pin
Richard Deeming4-Apr-19 10:28
communityengineerRichard Deeming4-Apr-19 10:28 
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; // Works
MyClass<Guid> c = b; // Won't compile - needs an explicit cast
And:
MyClass<Guid, Guid, Guid, Guid> a = new MyClass<Guid, Guid, Guid, Guid>();
MyClass<Guid> b = (MyClass<Guid>)a; // Compiles, but fails at runtime
MyClass<Guid> c = a as MyClass<Guid>; // Compiles and runs, but result is null


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."
- Homer

GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff5-Apr-19 5:03
mveBillWoodruff5-Apr-19 5:03 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
Richard Deeming5-Apr-19 6:34
communityengineerRichard Deeming5-Apr-19 6:34 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff5-Apr-19 17:37
mveBillWoodruff5-Apr-19 17:37 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
Richard Deeming15-Apr-19 9:15
communityengineerRichard Deeming15-Apr-19 9:15 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff15-Apr-19 20:06
mveBillWoodruff15-Apr-19 20:06 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
Richard Deeming16-Apr-19 8:32
communityengineerRichard Deeming16-Apr-19 8:32 
AnswerRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff5-Apr-19 21:12
mveBillWoodruff5-Apr-19 21:12 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
Gerry Schmitz6-Apr-19 12:03
mveGerry Schmitz6-Apr-19 12:03 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff6-Apr-19 12:20
mveBillWoodruff6-Apr-19 12:20 
GeneralRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff6-Apr-19 16:44
mveBillWoodruff6-Apr-19 16:44 
AnswerRe: Simplify usage of a complex generic class for convenience Pin
BillWoodruff6-Apr-19 13:57
mveBillWoodruff6-Apr-19 13:57 
QuestionWhere are the libraries located in C#? Pin
Brian_TheLion3-Apr-19 21:15
MemberBrian_TheLion3-Apr-19 21:15 
AnswerRe: Where are the libraries located in C#? Pin
OriginalGriff3-Apr-19 22:34
communityengineerOriginalGriff3-Apr-19 22:34 
GeneralRe: Where are the libraries located in C#? Pin
Brian_TheLion4-Apr-19 0:20
MemberBrian_TheLion4-Apr-19 0:20 
GeneralRe: Where are the libraries located in C#? Pin
OriginalGriff4-Apr-19 0:28
communityengineerOriginalGriff4-Apr-19 0:28 
GeneralRe: Where are the libraries located in C#? Pin
Brian_TheLion4-Apr-19 1:06
MemberBrian_TheLion4-Apr-19 1:06 
GeneralRe: Where are the libraries located in C#? Pin
OriginalGriff4-Apr-19 0:31
communityengineerOriginalGriff4-Apr-19 0:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.