Programming/.Net
C# 확장 메서드
Rusi(루시)
2011. 9. 21. 16:05
public static class ExtMethod
{
public static string ConvertTen(this string s)
{
string returnStr = "";
for (int i = 0; i < 10; i++)
{
returnStr += s;
}
return returnStr;
}
}
string 변수에서 '.' 찍고 난 다음 나오는 메서드에 추가하고 싶을때 씀
ex)
string a = "a";
Console.WriteLine(a.ConvertTen());
하면 a가 10개 찍혀서 나온다
string 변수에서 '.' 찍고 난 다음 나오는 메서드에 추가하고 싶을때 씀
ex)
string a = "a";
Console.WriteLine(a.ConvertTen());
하면 a가 10개 찍혀서 나온다