C나 C++에서 주로 많이 쓰이는 인라인 대입 표현은 C#에서도 여전히 활용하기 편리한 표현법인것 같다.

string strInput = null;

if ((strInput = Console.In.ReadLine()).Trim().Length > 0)
  Console.Out.Write(strInput);


위와 같이 쓰이는 것이 switch 구문에서도 통했다.

string strInput = null;

switch((strInput = Console.In.ReadLine()))
{
  case null: break;
  case "": break;

  default:
     switch(strInput.Trim())
     {
        case "": break;
        case "body": case "html": case "p": // ...
           return true;
     }
     break;
}

return true;


크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Windows Azure MVP 남정현 (rkttu.com)