c# 기초구문 업데이트 완료
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
var t = new { Name = "홍길동", Age = 20 };
|
||||
string s = t.Name;
|
||||
}
|
||||
|
||||
private void RunTest()
|
||||
{
|
||||
var v = new[] {
|
||||
new { Name="Lee", Age=33, Phone="02-111-1111" },
|
||||
new { Name="Kim", Age=25, Phone="02-222-2222" },
|
||||
new { Name="Park", Age=37, Phone="02-333-3333" },
|
||||
};
|
||||
|
||||
// LINQ Select를 이용해 Name과 Age만 갖는 새 익명타입 객체들을 리턴.
|
||||
var list = v.Where(p => p.Age >= 30).Select(p => new { p.Name, p.Age });
|
||||
foreach (var a in list)
|
||||
{
|
||||
Debug.WriteLine(a.Name + a.Age);
|
||||
}
|
||||
}
|
||||
|
||||
private (string name, int age) Test()
|
||||
{
|
||||
return ("Stive", 45);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user