Поскольку я использую эти интерфейсы для многих классов, это должно быть так:
Код: Выделить всё
public interface IClassA
{
string Word { get; }
}
public interface ITest where TClassA : IClassA
{
TClassA A { get; }
}
Код: Выделить всё
public class ClassA : IClassA
{
public string Word
{
get;
private set;
}
public string Sentence
{
get;
private set;
}
public ClassA(string word, string sentence)
{
this.Word = word;
this.Sentence = sentence;
}
}
public class Test : ITest
{
public ClassA A
{
get;
private set;
}
public Test(ClassA a)
{
this.A = a;
}
}
Код: Выделить всё
public static void Main(string[] args)
{
ClassA a = new ClassA("hey", "hey world!");
Test t = new Test(a);
Print((ITest)t);
}
public static void Print(ITest t)
{
Console.WriteLine(t.A.Word);
}
Как я могу ее решить?
спасибо!
Подробнее здесь: https://stackoverflow.com/questions/400 ... interfaces
Мобильная версия