Created
January 20, 2011 10:12
-
-
Save cz75hiro/787695 to your computer and use it in GitHub Desktop.
Linqメソッドで遊ぶ 例外
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 hoge1List = new List<inheritHoge1>(); | |
hoge1List.Add(new inheritHoge1() { a = "hoge1" }); | |
var hoge2List = new List<inheritHoge2>(); | |
var hoge = new inheritHoge2() { a = "hoge3" }; | |
hoge2List.Add(hoge); | |
hoge2List.Add(new inheritHoge2() { a = "hoge2" }); | |
hoge2List.Add(new inheritHoge2() { a = "hoge1" }); | |
hoge2List.Add(hoge); | |
var union = hoge1List.Select(x => (Hoge)x).Union(hoge2List); | |
foreach (var item in union) | |
{ | |
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