Created
January 20, 2011 11:00
-
-
Save cz75hiro/787734 to your computer and use it in GitHub Desktop.
Selectで実行時エラー
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Linqメソッドで遊ぶ | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var list = new List<Hoge>(){new inheritHoge1() { a = "hoge1" }, | |
new inheritHoge2() { a = "hoge2" }}; | |
var p = list.Select(x => (inheritHoge1)x); | |
foreach (var item in p) | |
{ | |
Console.WriteLine(item.a); | |
} | |
Console.Read(); | |
} | |
} | |
class Hoge | |
{ | |
public string a = string.Empty; | |
} | |
class inheritHoge1 : Hoge | |
{ | |
} | |
class inheritHoge2 : Hoge | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment