IEnumerable<TSource> 를 반환합니다.
public class Example
{
public static void Main()
{
Console.Write("<< Enumerable.Concat 출력 예제 >> \n");
Code[] codeOne = GetBeta();
Code[] codeTwo = GetAlpha();
IEnumerable<string> query =
codeOne.Select(beta => beta.CodeName).Concat(codeTwo.Select(alpha => alpha.CodeName));
foreach (string name in query)
{
Console.WriteLine(name);
}
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
static Code[] GetBeta()
{
Code[] betas = { new Code { CodeName= "betas1", CodeGrade=8 }, new Code { CodeName= "betas2", CodeGrade=4 }, new Code { CodeName= "betas3", CodeGrade=1 } };
return betas;
}
static Code[] GetAlpha()
{
Code[] Alphas = { new Code { CodeName= "Alphas1", CodeGrade=3 }, new Code { CodeName= "Alphas2", CodeGrade=14 }, new Code { CodeName= "Alphas3", CodeGrade=9 } };
return Alphas;
}
}
class Code
{
public string CodeName { get; set; }
public int CodeGrade { get; set; }
}
public class Example
{
public static void Main()
{
Console.Write("<< Enumerable.Concat 출력 예제 >> \n");
Code[] codeOne = GetBeta();
Code[] codeTwo = GetAlpha();
IEnumerable<string> query =
new[] { codeOne.Select(beta => beta.CodeName), codeTwo.Select(alpha => alpha.CodeName) }
.SelectMany(name => name);
foreach (string name in query)
{
Console.WriteLine(name);
}
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
static Code[] GetBeta()
{
Code[] betas = { new Code { CodeName= "betas1", CodeGrade=8 }, new Code { CodeName= "betas2", CodeGrade=4 }, new Code { CodeName= "betas3", CodeGrade=1 } };
return betas;
}
static Code[] GetAlpha()
{
Code[] Alphas = { new Code { CodeName= "Alphas1", CodeGrade=3 }, new Code { CodeName= "Alphas2", CodeGrade=14 }, new Code { CodeName= "Alphas3", CodeGrade=9 } };
return Alphas;
}
}
class Code
{
public string CodeName { get; set; }
public int CodeGrade { get; set; }
}