-
-
Save cz75hiro/787681 to your computer and use it in GitHub Desktop.
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) | |
{ | |
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