Skip to content

Instantly share code, notes, and snippets.

@cz75hiro
Created January 20, 2011 11:00
Show Gist options
  • Save cz75hiro/787734 to your computer and use it in GitHub Desktop.
Save cz75hiro/787734 to your computer and use it in GitHub Desktop.
Selectで実行時エラー
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