Closed sam-wheat closed 5 years ago
@sam-wheat
I made a few changes and this compiles for me:
public class Program2
{
public Program2()
{
Selector<Selectable> stringSelector = new Selector<Selectable>(); // does not build
}
}
public interface ISelectable<T>
{
bool IsSelected { get; set; }
T Item { get; set; }
}
// This is the class that needs to change:
public class Selectable : ISelectable<Selectable>
{
public bool IsSelected { get; set; }
public Selectable Item { get; set; }
}
public class Selector<T> where T:ISelectable<T> { }
I'll close this as answered.
In this document
This class is defined:
And this statement is made:
In the code below I am naming my example class Selector instead of AGenericClass
and using interfacte ISelectable instead of IComparable { }
That is the only difference.
Can you please show me how to create an instance of
Selector
class using the same definition asAGenericClass
shown in the c# documentation?Again
AGenericClass
andSelector
differ in name only:Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.