[閒聊] C# quiz

看板C_Sharp作者 (Harold)時間18年前 (2007/11/25 08:16), 編輯推噓3(300)
留言3則, 3人參與, 最新討論串1/1
前幾天在網路上看到一個有趣的C# quiz, 貼出來試試看 以下的程式可否 compile, 為什麼? using System; using System.Collections.Generic; class Program { static void Main(string[] args) { IEnumerable<Inter1> ienum1 = new Class1[] { new Class1() }; foreach (Class2 c in ienum1) { Console.WriteLine(c); } } } public interface Inter1 { } public class Class1 : Inter1 { } public class Class2 { } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 67.161.17.127

11/25 23:08, , 1F
跟Class2有關係嗎?
11/25 23:08, 1F

11/25 23:11, , 2F
http://0rz.tw/c53ja yes it compiles, and here's why
11/25 23:11, 2F

12/16 11:40, , 3F
po在這邊的題目敘述有完整嗎?
12/16 11:40, 3F
文章代碼(AID): #17IBx8UA (C_Sharp)