public class Example
{
public static void Main()
{
Console.Write("<< Enumerable.ToArray 출력 예제 >> \n");
List<CodeFactory> codefactories =
new List<CodeFactory>
{ new CodeFactory { Company = "서울시 서초구", Weight = 25.2 },
new CodeFactory { Company = "부산시 금정구", Weight = 18.7 },
new CodeFactory { Company = "성남시 분당구", Weight = 6.0 },
new CodeFactory { Company = "수원시 권선구", Weight = 33.8 } };
// TSource[] 타입의 배열를 반환.
string[] companies = codefactories.Select(factory => factory.Company).ToArray();
foreach (string company in companies)
{
Console.WriteLine(company);
}
Console.WriteLine(System.Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
class CodeFactory
{
public string Company { get; set; }
public double Weight { get; set; }
}