728x90
์ฐ์ต๋ฌธ์ 1
using System;
namespace Ex9_1
{
class NameCard
{
private int age;
private string name;
public int Age { get; set; }
public string Name { get; set; }
}
class MainApp
{
static void Main(string[] args)
{
NameCard ACard = new NameCard();
ACard.Age = 20;
ACard.Name = "๊น๊ฐ์";
Console.WriteLine($"{ACard.Name}์ ๋์ด๋ {ACard.Age}์
๋๋ค.");
}
}
}
์ถ๋ ฅ ๊ฒฐ๊ณผ
๊น๊ฐ์์ ๋์ด๋ 20์
๋๋ค.
์ฐ์ต๋ฌธ์ 2
using System;
namespace Ex9_1
{
class MainApp
{
static void Main(string[] args)
{
var nameCard = new { Name = "๋ฐ์ํ", Age = 17};
Console.WriteLine("์ด๋ฆ: {0}, ๋์ด:{1}", nameCard.Name, nameCard.Age);
var complex = new { Real = 3, Imaginary = -12 };
Console.WriteLine("Real: {0}, Imaginary:{1}", complex.Real, complex.Imaginary);
}
}
}
์ถ๋ ฅ ๊ฒฐ๊ณผ
์ด๋ฆ: ๋ฐ์ํ, ๋์ด:17
Real: 3, Imaginary:-12
728x90
'C# > ์ด๊ฒ์ด C#์ด๋ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
48. System.Array (0) | 2022.02.24 |
---|---|
47. ๋ฐฐ์ด์ฐ๋ ์ด์ , ๋ฐฐ์ด ์ด๊ธฐํ ๋ฐฉ๋ฒ 3๊ฐ์ง (0) | 2022.02.24 |
45. ์ถ์ํด๋์ค์ ํ๋กํผํฐ (0) | 2022.02.24 |
44. ์ธํฐํ์ด์ค์ ํ๋กํผํฐ (0) | 2022.02.23 |
43. ๋ฌด๋ช ํ์ (0) | 2022.02.23 |