| ■No26108 (ま さん) に返信
>
>
> ん〜、なんだかよくわかんないんだけど、派生クラスのサンプル載せたよね。
全然違った。;;
C#2005 Express 版のやつでテスト確認。
class Program
{
static void Main(string[] args)
{
new Program().test1();
new Program().test2();
}
private void test1()
{
List<string> my = new List<string>();
my.Add("OKOD");
my.Add("GOD");
my.Add("ODD");
my.Add("EVEN");
my.Add("POD");
my.Add("TODO");
my.Add("QUEEN");
List<string> me = new List<string>();
string key = "OD";
my.ForEach(delegate(string s)
{
if (s.IndexOf(key) > -1) me.Add(s);
});
Console.WriteLine("----- result -----");
me.ForEach(delegate(string s)
{
Console.WriteLine("{0}", s);
});
Console.In.ReadLine();
}
private void test2()
{
ArrayList list1 = new ArrayList();
ArrayList list2 = new ArrayList();
list1.Add("OKOD");
list1.Add("GOD");
list1.Add("ODD");
list1.Add("EVEN");
list1.Add("POD");
list1.Add("TODO");
list1.Add("QUEEN");
string key = "OD";
foreach (string s in list1)
{
if (s.IndexOf(key) > -1) list2.Add(s);
}
Console.WriteLine("------ result2 ------");
foreach (string s in list2)
{
Console.WriteLine("{0}", s);
}
Console.In.ReadLine();
}
}
こうだす。きっと熟練さんからしたらダメだしものだろうけど
これが精一杯w。
|