C#C
C#3y ago
Starlk

❔ a question about generics

vague title because I don't know how would I word it

void Welcome<T>(T message) where T : Parent<T> { }

internal abstract record Parent<T>();

internal sealed record Child() : Parent<string>;


this might be a weird question, but how could I achieve something like this:
Welcome<Child>("string");

where the provided T type might change the message type, for example, if Child was Parent<int> then Welcome<Child>() would for an integer
Was this page helpful?