CODEKILLER

반응형

> IEnumerable<T> 로 형식을 반환.

Enumerable.AsEnumerable 메서드
Enumerable.AsEnumerable 메서드

public class Example
{
    public static void Main()
    {
        Console.Write("<< Enumerable.AsEnumerable 출력 예제 >> \n");

        CodeGen<string> lstCodes =
            new CodeGen<string> { "abc", "def", "ghi", "jkl", "mno", "oqr", "stu" };

        IEnumerable<string> query = lstCodes.AsEnumerable().Where(code => code.Contains("o"));

        foreach(var item in query)
        {
            Console.WriteLine($"value : {item}");
        }

        Console.WriteLine(System.Environment.NewLine);
        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }
}

class CodeGen<T> : List<T>
{
    public IEnumerable<T> Where(Func<T, bool> predicate)
    {
        return Enumerable.Where(this, predicate);
    }
}
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band