Skip to content

Instantly share code, notes, and snippets.

@cz75hiro
Created January 20, 2011 10:00
Show Gist options
  • Save cz75hiro/787681 to your computer and use it in GitHub Desktop.
Save cz75hiro/787681 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Linqメソッドで遊ぶ
{
class Program
{
static void Main(string[] args)
{
List<intheritHoge1> hoge1List = new List<intheritHoge1>();
hoge1List.Add(new intheritHoge1() { a = "hoge1" });
List<intheritHoge2> hoge2List = new List<intheritHoge2>();
hoge2List.Add(new intheritHoge2() { a = "hoge2" });
hoge2List.Add(new intheritHoge2() { a = "hoge1" });
var union = hoge1List.Select(x => (Hoge)x).Union(hoge2List);
if (true)
{
union = union.Where(x => x.a == "hoge2");
}
foreach (var item in union)
{
Console.WriteLine(item.a);
}
Console.Read();
}
}
class Hoge
{
public string a = string.Empty;
}
class intheritHoge1 : Hoge
{
}
class intheritHoge2 : Hoge
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment