728x90
[C#] ํด๋์ค๋ฅผ ๋ฐฐ์ด๋ก ์ ์ธํ๊ธฐ
์.. ์ด๊ฑฐ ์ ๋ง ๋ชฐ๋๋์? C# ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ๋ฐฐ์ด๋ก ์ ์ธํ ๋ ๋์ ์ผ๋ก ์ ์ฒด ํ ๋นํ ๋ค, ๋ค์ ํ๋ํ๋ ๋ค ํ ๋นํด์ค์ผ ํ๋ค๋. ์ด๊ฑฐ ๋๋ฌธ์ ์ด์ ์ค๋ ํค๋ฉ๊ฑฐ ์๊ฐํ๋ฉด..@#$%& ์ถ์ฒ:hazelstyle.e
topnanis.tistory.com
์ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํด์ ์์ ๋ฅผ ์์ฑํ์๋ค.
using System;
namespace MoreOnArray
{
class Test
{
int number;
string name;
public int Number { get; set; }
public string Name { get; set; }
public void TestShow()
{
Console.WriteLine($"์ซ์๋ {this.Number}... ์ด๋ฆ์ {this.Name}");
}
}
class MainApp
{
static void Main(string[] args)
{
Test[] tests = new Test[100];
for (int i=0; i<tests.Length; i++)
tests[i] = new Test();
if(tests[0]!=null)
{
tests[0].Number = 7;
tests[0].Name = "์ฉ์์ฒ ";
tests[0].TestShow();
}
}
}
}
์ถ๋ ฅ
์ซ์๋ 7... ์ด๋ฆ์ ์ฉ์์ฒ
์์ ์ C# ํด๋์ค์ ์ธ์คํด์ค๋ฅผ ๋ฐฐ์ด๋ก ์ ์ธํ ๋ ๋์ ์ผ๋ก ์ ์ฒด ํ ๋นํ ๋ค, ๋ค์ ํ๋ํ๋ ๋ค ํ ๋นํด์ฃผ์ด์ผ ํ๋ค๋ ๊ฒ
728x90
'C# > C#' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Array.CreateInstance ๋ฉ์๋ (0) | 2022.10.09 |
---|---|
[C#] ์ ์ ์ซ์ ํ์ (0) | 2022.06.11 |
ํ๋, ๋ฉค๋ฒ, ์ง์ญ๋ณ์, ์ ์ ํ๋, ์ ์ ๋ฉ์๋ ๊ฐ๋ ์ ๋ฆฌ (0) | 2022.02.14 |
[C#]๋ฌธ์์ด ์ถ๋ ฅ ์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ (0) | 2022.02.04 |
[C# ์ฝ์] 5x5 ๋๊ทธ๋ผ๋ฏธํ ์ถ๋ ฅ (0) | 2022.02.02 |