作者deuter (Harold)
看板C_Sharp
標題[閒聊] C# quiz
時間Sun Nov 25 08:16:07 2007
前幾天在網路上看到一個有趣的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
推 tomex:跟Class2有關係嗎? 11/25 23:08
推 liunate:po在這邊的題目敘述有完整嗎? 12/16 11:40