我对以下一点感到困惑。
考虑到这一类别:
public class SomeClassToBeCasted
{
public static implicit operator string(SomeClassToBeCasted rightSide)
{
return rightSide.ToString();
}
}
在我试图做以下工作时,为什么有人投掷了英勇的欺骗?
IList<SomeClassToBeCasted> someClassToBeCastedList
= new List<SomeClassToBeCasted> {new SomeClassToBeCasted()};
IEnumerable<string> results = someClassToBeCastedList.Cast<string>();
foreach (var item in results)
{
Console.WriteLine(item.GetType());
}