I am translating a bunch of typescript classes and interfaces to C# (for javascript interop for those wondering why)
One example that I am not sure how to translate from typescript is this:
interface CellArray extends Array<Cell> {
addClass(className: string): CellArray;
removeClass(className: string): CellArray;
html(html: string): CellArray;
invalidate(): CellArray;
}
If i'm reading that correctly, that interface is extending the type of an array of type cell... while also having some return methods.
Is there a way to translate this to C#?
Thanks!
C# interfaces cannot directly inherit from Lists (because they are classes) - but they can inherit from any interface such as
IList
orIEnumerable
:Array is a class which inherits from
IList
andIEnumerable
. So you can inherit fromIList<T>
Or you can inherit from
IEnumerable
: