Section 49.1: 순서가 필요없는 명명된 인자 (Named Argument) 사용하기

명명된 인자 (Named Argument) 를 사용하면, 인자의 순서를 사용자가 원하는 어떠한 순서대로 기술하여도 정상 동작에 문제가 없다.

Sample 메소드:

public static string Sample(string left, string right) { return string.Join("-",left,right); }

Sample 메소드 호출:

Console.WriteLine (Sample(left:"A",right:"B")); Console.WriteLine (Sample(right:"A",left:"B"));

결과:

A-B B-A
본 문서는 C# Notes for Professionals (라이센스:CC-BY-SA) 를 한글로 번역한 문서입니다. 번역상 오류가 있을 수 있으므로 정확한 내용은 원본 문서를 참고하세요.

[출처] https://books.goalkicker.com/CSharpBook/

반응형

+ Recent posts