Код: Выделить всё
public class ForeignKey {
public string Id {get;}
public TableA TableA {get;}
public TableB TableB {get;}
public static implicit operator string(ForeignKey obj){ return obj.Id; }
public override string ToString() { return Id; }
/* various operator overloads */
}
Например, мне хотелось бы, чтобы это работало.
Код: Выделить всё
if (Key.EndsWith(someValue))
Код: Выделить всё
if (((string)Key).EndsWith(someValue))
// or
if (Key.Id.EndsWith(someValue))
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/462 ... conversion