I have the following Type in typescript
export type Excludable<T extends FilterValue> = T & { isExcluded?: boolean }
where FilterValue:
export type FilterValue = {
id: number,
label: string,
}
type T could be the following:
export type AreaFilterValue = FilterValue & {
type: "Area",
taxonomy?: LocationTaxonomy,
}
Can I somehow write the above in C#?
ideally I would need something like:
public class Excludable<T> : T where T : FilterValue
{
bool? IsExcluded { get; set; }
}
but it shows an error of "Could not derive from T cause it's a type parameter"
What I am trying to achieve is to have an object like:
{ id, label }{ id, label, isExcluded }{ id, label, isExcluded, type, taxonomy }
Edit: I currently have set in C# that FilterValue has the isExcluded property
Ideally I would like to use it in my code like follows:
public Excludable<AreaFilterValue>[] OpenAreas { get; set; }