using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
//拡張メソッドを定義するクラスはstaticにさえしておけば、どんな名前にしてもいいよ!Class名は飾りだよ
static class OresamanoTukuttaExtendMethods
{
public static bool In(this string input, params string[] others)
{
return others.AsEnumerable().Any(a => a == input);
}
}
class Program
{
static void Main(string[] args)
{
string s1 = "TEST";
string[] ss1 = new string[] {"aaa","bbb","ccc" };
Console.WriteLine("{0}に等しい文字がss1配列にあるか?{1}", s1, s1.In(ss1));
string[] ss2 = new string[] { "aaa", "TEST", "ccc" };
Console.WriteLine("{0}に等しい文字がss2配列にあるか?{1}", s1, s1.In(ss2));
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CnVzaW5nIFN5c3RlbS5UZXh0OwoKbmFtZXNwYWNlIENvbnNvbGVBcHBsaWNhdGlvbjMKewogICAgLy/mi6HlvLXjg6Hjgr3jg4Pjg4njgpLlrprnvqnjgZnjgovjgq/jg6njgrnjga9zdGF0aWPjgavjgZXjgYjjgZfjgabjgYrjgZHjgbDjgIHjganjgpPjgarlkI3liY3jgavjgZfjgabjgoLjgYTjgYTjgojvvIFDbGFzc+WQjeOBr+mjvuOCiuOBoOOCiAogICAgc3RhdGljIGNsYXNzIE9yZXNhbWFub1R1a3V0dGFFeHRlbmRNZXRob2RzCiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyBib29sIEluKHRoaXMgc3RyaW5nIGlucHV0LCBwYXJhbXMgc3RyaW5nW10gb3RoZXJzKQogICAgICAgIHsKICAgICAgICAgICAgcmV0dXJuIG90aGVycy5Bc0VudW1lcmFibGUoKS5BbnkoYSA9PiBhID09IGlucHV0KTsKICAgICAgICB9CiAgICB9CgogICAgY2xhc3MgUHJvZ3JhbQogICAgewogICAgICAgIHN0YXRpYyB2b2lkIE1haW4oc3RyaW5nW10gYXJncykKICAgICAgICB7CiAgICAgICAgICAgIHN0cmluZyBzMSA9ICJURVNUIjsKICAgICAgICAgICAgc3RyaW5nW10gc3MxID0gbmV3IHN0cmluZ1tdIHsiYWFhIiwiYmJiIiwiY2NjIiB9OwogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiezB944Gr562J44GX44GE5paH5a2X44GMc3Mx6YWN5YiX44Gr44GC44KL44GL77yfezF9IiwgczEsIHMxLkluKHNzMSkpOwoKICAgICAgICAgICAgc3RyaW5nW10gc3MyID0gbmV3IHN0cmluZ1tdIHsgImFhYSIsICJURVNUIiwgImNjYyIgfTsKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoInswfeOBq+etieOBl+OBhOaWh+Wtl+OBjHNzMumFjeWIl+OBq+OBguOCi+OBi++8n3sxfSIsIHMxLCBzMS5JbihzczIpKTsKCiAgICAgICAgfQogICAgfQp9Cg==