C#从IEnumerable 到T

问题描述 投票:-4回答:1

任何人都可以用文章/电子书来解释吗?>

  • 编译成功
  • 运行时正常
  • 我已经检查了IEnumerable <>和IEnumerable的源代码,但一无所获仅供参考,这不适用于列表

class Program
{
    public class Person
    {
        public long Age { get; set; }
    }

    static void Main(string[] args)
    {
        IEnumerable<Person> list = new List<Person>();
        ((Person)list).Age = 5;
    }
}

任何人都可以用文章/电子书来解释,编译正常,运行时正常,我已经检查了IEnumerable <>和IEnumerable的源代码,没发现仅供参考,这不适用于List类...

c# ienumerable implicit-conversion explicit-conversion
1个回答
-2
投票
© www.soinside.com 2019 - 2024. All rights reserved.