out
out 키워드를 사용하면 변수를 전달하기전 초기화 하지 않고도 전달이 가능
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int a;
Add(out a);
Console.WriteLine("a={0}", a);
}
static void Add(out int a)
{
a = 100;
}
}
}
결과:
a=100
'Programming > C#' 카테고리의 다른 글
params (0) | 2017.08.06 |
---|---|
foreach (0) | 2017.08.06 |
변수 출력 (0) | 2017.08.06 |
c# 동적으로 textbox 생성하기 (0) | 2017.08.05 |
winform 파일 쓰기 (0) | 2017.08.05 |