본문 바로가기
프로그래밍/C#

C# 괄호 알아보기

by bantomak 2023. 3. 20.

 


괄호 종류

  한글 명칭 영어 명칭
() 소괄호 Round Brackets 또는 Parentheses
[] 대괄호 Square Brackets 또는 Brackets
{} 중괄호 Curly Brackets 또는 Braces
<> 홑화살괄호 Angle Brackets 또는 Chevrons

 

복합문에서의 중괄호 배치 (들여쓰기 스타일)

중괄호는 사이에 문장이 입력되기 때문에 간격이 많이 벌어지게 됩니다. 그래서 이에 따른 많은 코딩 스타일이 존재하게 됩니다.

 

중괄호 배치 스타일
while (x == y)
{
    something();
    somethingelse();
}
Allman
while (x == y) {
    something();
    somethingelse();
}
K&R
while (x == y)
  {
    something ();
    somethingelse ();
  }
GNU
while (x == y)
    {
    something();
    somethingelse();
    }
Whitesmith
while (x == y)
{   something();
    somethingelse();
}
Horstmann
while (x == y)
{   something();
    somethingelse(); }
Pico
while (x == y) {
    something();
    somethingelse();
    }
Ratliff
while (x == y)
  { something();
    somethingelse(); }
Lisp
#define W(c,b) {while(c){b}}
W(x==y,s();se();)
APL

 

댓글