다음을 통해 공유


C# 서식 옵션

이 문서의 서식 옵션은 C# 코드에만 적용됩니다. 코드 스타일 규칙 IDE0055대한 옵션입니다.

새 줄 옵션

새 줄 옵션은 새 줄을 사용하여 코드 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_new_line_before_open_brace = methods, properties, control_blocks, types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

csharp_new_line_before_open_brace

이 옵션은 열린 중괄호 { 이전 코드와 동일한 줄에 배치해야 하는지 또는 새 줄에 배치해야 하는지와 관련이 있습니다. 이 규칙에서는 모든 , 없음 또는 메서드 또는 속성과 같은 하나 이상의 코드 요소를지정하여 이 규칙을 적용해야 하는 시기를 정의합니다. 여러 코드 요소를 지정하려면 쉼표(,)로 구분합니다.

재산 묘사
옵션 이름 csharp_new_line_before_open_brace
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 all 모든 식("Allman" 스타일)의 새 줄에 중괄호가 있어야 합니다.
none 모든 식에 대해 중괄호가 동일한 줄에 있어야 합니다("K&R").
accessors, anonymous_methods, anonymous_types, control_blocks, events, indexers,
lambdas, local_functions, methods, object_collection_array_initializers, properties, types
지정된 코드 요소("Allman" 스타일)의 새 줄에 중괄호가 있어야 합니다.
기본 옵션 값 all

코드 예제:

// csharp_new_line_before_open_brace = all
void MyMethod()
{
    if (...)
    {
        ...
    }
}

// csharp_new_line_before_open_brace = none
void MyMethod() {
    if (...) {
        ...
    }
}

csharp_new_line_before_else

재산 묘사
옵션 이름 csharp_new_line_before_else
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true else 문을 새 줄에 배치합니다.
false else 문을 같은 줄에 배치합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_else = true
if (...) {
    ...
}
else {
    ...
}

// csharp_new_line_before_else = false
if (...) {
    ...
} else {
    ...
}

csharp_new_line_before_catch

재산 묘사
옵션 이름 csharp_new_line_before_catch
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true catch 문을 새 줄에 배치합니다.
false catch 문을 같은 줄에 배치합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_catch = true
try {
    ...
}
catch (Exception e) {
    ...
}

// csharp_new_line_before_catch = false
try {
    ...
} catch (Exception e) {
    ...
}

csharp_new_line_before_finally

재산 묘사
옵션 이름 csharp_new_line_before_finally
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true finally 문이 닫는 중괄호 뒤의 새 줄에 있어야 합니다.
false finally 문이 닫는 중괄호와 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_finally = true
try {
    ...
}
catch (Exception e) {
    ...
}
finally {
    ...
}

// csharp_new_line_before_finally = false
try {
    ...
} catch (Exception e) {
    ...
} finally {
    ...
}

csharp_new_line_before_members_in_object_initializers

재산 묘사
옵션 이름 csharp_new_line_before_members_in_object_initializers
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 개체 이니셜라이저의 멤버가 별도의 줄에 있어야 합니다.
false 개체 이니셜라이저의 멤버가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_members_in_object_initializers = true
var z = new B()
{
    A = 3,
    B = 4
}

// csharp_new_line_before_members_in_object_initializers = false
var z = new B()
{
    A = 3, B = 4
}

csharp_new_line_before_members_in_anonymous_types

재산 묘사
옵션 이름 csharp_new_line_before_members_in_anonymous_types
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 익명 형식의 멤버가 별도의 줄에 있어야 합니다.
false 익명 형식의 멤버가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_before_members_in_anonymous_types = true
var z = new
{
    A = 3,
    B = 4
}

// csharp_new_line_before_members_in_anonymous_types = false
var z = new
{
    A = 3, B = 4
}

csharp_new_line_between_query_expression_clauses

재산 묘사
옵션 이름 csharp_new_line_between_query_expression_clauses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 쿼리 식 절의 요소가 별도의 줄에 있어야 합니다.
false 쿼리 식 절의 요소가 동일한 줄에 있어야 합니다.
기본 옵션 값 true

코드 예제:

// csharp_new_line_between_query_expression_clauses = true
var q = from a in e
        from b in e
        select a * b;

// csharp_new_line_between_query_expression_clauses = false
var q = from a in e from b in e
        select a * b;

들여쓰기 옵션

들여쓰기 옵션은 들여쓰기를 사용하여 코드의 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = true

csharp_indent_case_contents

재산 묘사
옵션 이름 csharp_indent_case_contents
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 들여쓰기 switch 사례 내용
false 사례 내용을 들여쓰지 switch 마세요.
기본 옵션 값 true

코드 예제:

// csharp_indent_case_contents = true
switch(c) {
    case Color.Red:
        Console.WriteLine("The color is red");
        break;
    case Color.Blue:
        Console.WriteLine("The color is blue");
        break;
    default:
        Console.WriteLine("The color is unknown.");
        break;
}

// csharp_indent_case_contents = false
switch(c) {
    case Color.Red:
    Console.WriteLine("The color is red");
    break;
    case Color.Blue:
    Console.WriteLine("The color is blue");
    break;
    default:
    Console.WriteLine("The color is unknown.");
    break;
}

csharp_indent_switch_labels

재산 묘사
옵션 이름 csharp_indent_switch_labels
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true switch 레이블 들여쓰기
false switch 레이블 들여쓰기 안 함
기본 옵션 값 true

코드 예제:

// csharp_indent_switch_labels = true
switch(c) {
    case Color.Red:
        Console.WriteLine("The color is red");
        break;
    case Color.Blue:
        Console.WriteLine("The color is blue");
        break;
    default:
        Console.WriteLine("The color is unknown.");
        break;
}

// csharp_indent_switch_labels = false
switch(c) {
case Color.Red:
    Console.WriteLine("The color is red");
    break;
case Color.Blue:
    Console.WriteLine("The color is blue");
    break;
default:
    Console.WriteLine("The color is unknown.");
    break;
}

csharp_indent_labels

재산 묘사
옵션 이름 csharp_indent_labels
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 flush_left 레이블은 맨 왼쪽 열에 배치됩니다.
one_less_than_current 레이블은 현재 컨텍스트에 덜 들여쓰기 상태로 배치됩니다.
no_change 레이블은 현재 컨텍스트와 동일한 들여쓰기 위치에 배치됩니다.
기본 옵션 값 one_less_than_current

코드 예제:

// csharp_indent_labels= flush_left
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
error:
        throw new Exception(...);
    }
}

// csharp_indent_labels = one_less_than_current
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
    error:
        throw new Exception(...);
    }
}

// csharp_indent_labels= no_change
class C
{
    private string MyMethod(...)
    {
        if (...) {
            goto error;
        }
        error:
        throw new Exception(...);
    }
}

csharp_indent_block_contents

재산 묘사
옵션 이름 csharp_indent_block_contents
적용 가능한 언어 C#
옵션 값 true 들여쓰기 블록 내용입니다.
false 콘텐츠를 들여쓰지 마세요.
기본 옵션 값 true

코드 예제:

// csharp_indent_block_contents = true
static void Hello()
{
    Console.WriteLine("Hello");
}

// csharp_indent_block_contents = false
static void Hello()
{
Console.WriteLine("Hello");
}

csharp_indent_braces

재산 묘사
옵션 이름 csharp_indent_braces
적용 가능한 언어 C#
옵션 값 true 들여쓰기 중괄호
false 중괄호를 들여쓰지 마세요.
기본 옵션 값 false

코드 예제:

// csharp_indent_braces = true
static void Hello()
    {
    Console.WriteLine("Hello");
    }

// csharp_indent_braces = false
static void Hello()
{
    Console.WriteLine("Hello");
}

csharp_indent_case_contents_when_block

재산 묘사
옵션 이름 csharp_indent_case_contents_when_block
적용 가능한 언어 C#
옵션 값 true 블록인 경우 문 목록을 들여쓰고 switch 문의 사례에 대해 중괄호를 중괄호로 묶습니다.
false 블록인 경우 switch 문의 사례에 대해 문 목록과 중괄호를 들여쓰지 마세요.
기본 옵션 값 true

코드 예제:

// csharp_indent_case_contents_when_block = true
case 0:
    {
        Console.WriteLine("Hello");
        break;
    }

// csharp_indent_case_contents_when_block = false
case 0:
{
    Console.WriteLine("Hello");
    break;
}

간격 옵션

간격 옵션은 공백 문자를 사용하여 코드 서식을 지정하는 경우와 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = control_flow_statements, type_casts
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_parameter_list_parentheses = true
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = true
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_after_comma = true
csharp_space_before_comma = false
csharp_space_after_dot = false
csharp_space_before_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false
csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false

csharp_space_after_cast

재산 묘사
옵션 이름 csharp_space_after_cast
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 캐스트와 값 사이에 공백 문자를 배치합니다.
false 캐스트와 값 사이의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_after_cast = true
int y = (int) x;

// csharp_space_after_cast = false
int y = (int)x;

csharp_space_after_keywords_in_control_flow_statements

재산 묘사
옵션 이름 csharp_space_after_keywords_in_control_flow_statements
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true for 루프와 같은 제어 흐름 문에서 키워드 뒤의 공백 문자를 배치합니다.
false for 루프와 같은 제어 흐름 문의 키워드 뒤 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_keywords_in_control_flow_statements = true
for (int i;i<x;i++) { ... }

// csharp_space_after_keywords_in_control_flow_statements = false
for(int i;i<x;i++) { ... }

csharp_space_between_parentheses

재산 묘사
옵션 이름 csharp_space_between_parentheses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 control_flow_statements 제어 흐름 문의 괄호 사이에 공백 배치
expressions 식의 괄호 사이에 공백 배치
type_casts 형식 캐스트에서 괄호 사이에 공백 배치
false(또는 다른 값) 괄호 사이에 공백을 사용하지 않는 것이 좋습니다†
기본 옵션 값 false

†이 규칙을 생략하거나 control_flow_statements, expressions또는 type_casts이외의 값을 사용하면 제어 흐름 문, 식 및 형식 캐스트의 괄호 사이의 공백이 제거됩니다.

코드 예제:

// csharp_space_between_parentheses = control_flow_statements
for ( int i = 0; i < 10; i++ ) { }

// csharp_space_between_parentheses = expressions
var z = ( x * y ) - ( ( y - x ) * 3 );

// csharp_space_between_parentheses = type_casts
int y = ( int )x;

// csharp_space_between_parentheses = false
for (int i = 0; i < 10; i++) { }
var z = (x * y) - ((y - x) * 3);
int y = (int)x;

csharp_space_before_colon_in_inheritance_clause

재산 묘사
옵션 이름 csharp_space_before_colon_in_inheritance_clause
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 형식 선언에서 기본 또는 인터페이스의 콜론 앞에 공백 문자를 배치합니다.
false 형식 선언에서 기본 또는 인터페이스에 대한 콜론 앞의 공간 제거
기본 옵션 값 true

코드 예제:

// csharp_space_before_colon_in_inheritance_clause = true
interface I
{

}

class C : I
{

}

// csharp_space_before_colon_in_inheritance_clause = false
interface I
{

}

class C: I
{

}

csharp_space_after_colon_in_inheritance_clause

재산 묘사
옵션 이름 csharp_space_after_colon_in_inheritance_clause
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 형식 선언에서 기본 또는 인터페이스의 콜론 다음에 공백 문자를 배치합니다.
false 형식 선언에서 기본 또는 인터페이스에 대한 콜론 뒤의 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_colon_in_inheritance_clause = true
interface I
{

}

class C : I
{

}

// csharp_space_after_colon_in_inheritance_clause = false
interface I
{

}

class C :I
{

}

csharp_space_around_binary_operators

재산 묘사
옵션 이름 csharp_space_around_binary_operators
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 before_and_after 이진 연산자 앞과 뒤에 공백 삽입
none 이진 연산자 앞과 뒤에 공백 제거
ignore 이진 연산자 주위의 공백 무시
기본 옵션 값 before_and_after

코드 예제:

// csharp_space_around_binary_operators = before_and_after
return x * (x - y);

// csharp_space_around_binary_operators = none
return x*(x-y);

// csharp_space_around_binary_operators = ignore
return x  *  (x-y);

csharp_space_between_method_declaration_parameter_list_parentheses

재산 묘사
옵션 이름 csharp_space_between_method_declaration_parameter_list_parentheses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 여는 괄호 뒤와 메서드 선언 매개 변수 목록의 닫는 괄호 앞에 공백 문자를 배치합니다.
false 여는 괄호 뒤와 메서드 선언 매개 변수 목록의 닫는 괄호 앞에 공백 문자를 제거합니다.
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_parameter_list_parentheses = true
void Bark( int x ) { ... }

// csharp_space_between_method_declaration_parameter_list_parentheses = false
void Bark(int x) { ... }

csharp_space_between_method_declaration_empty_parameter_list_parentheses

재산 묘사
옵션 이름 csharp_space_between_method_declaration_empty_parameter_list_parentheses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 메서드 선언에 대한 빈 매개 변수 목록 괄호 안에 공백 삽입
false 메서드 선언에 대한 빈 매개 변수 목록 괄호 내의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_empty_parameter_list_parentheses = true
void Goo( )
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

// csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_between_method_declaration_name_and_open_parenthesis

재산 묘사
옵션 이름 csharp_space_between_method_declaration_name_and_open_parenthesis
적용 가능한 언어 C#
옵션 값 true 메서드 선언에서 메서드 이름과 여는 괄호 사이에 공백 문자를 배치합니다.
false 메서드 선언에서 메서드 이름과 여는 괄호 사이의 공백 문자 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_declaration_name_and_open_parenthesis = true
void M () { }

// csharp_space_between_method_declaration_name_and_open_parenthesis = false
void M() { }

csharp_space_between_method_call_parameter_list_parentheses

재산 묘사
옵션 이름 csharp_space_between_method_call_parameter_list_parentheses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 여는 괄호 뒤와 메서드 호출의 닫는 괄호 앞에 공백 문자를 배치합니다.
false 여는 괄호 뒤와 메서드 호출의 닫는 괄호 앞에 공백 문자를 제거합니다.
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_parameter_list_parentheses = true
MyMethod( argument );

// csharp_space_between_method_call_parameter_list_parentheses = false
MyMethod(argument);

csharp_space_between_method_call_empty_parameter_list_parentheses

재산 묘사
옵션 이름 csharp_space_between_method_call_empty_parameter_list_parentheses
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 빈 인수 목록 괄호 안에 공백 삽입
false 빈 인수 목록 괄호 안의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_empty_parameter_list_parentheses = true
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo( );
}

// csharp_space_between_method_call_empty_parameter_list_parentheses = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_between_method_call_name_and_opening_parenthesis

재산 묘사
옵션 이름 csharp_space_between_method_call_name_and_opening_parenthesis
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 메서드 호출 이름과 여는 괄호 사이에 공백 삽입
false 메서드 호출 이름과 여는 괄호 사이의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_method_call_name_and_opening_parenthesis = true
void Goo()
{
    Goo (1);
}

void Goo(int x)
{
    Goo ();
}

// csharp_space_between_method_call_name_and_opening_parenthesis = false
void Goo()
{
    Goo(1);
}

void Goo(int x)
{
    Goo();
}

csharp_space_after_comma

재산 묘사
옵션 이름 csharp_space_after_comma
적용 가능한 언어 C#
옵션 값 true 쉼표 뒤에 공백 삽입
false 쉼표 뒤의 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_comma = true
int[] x = new int[] { 1, 2, 3, 4, 5 };

// csharp_space_after_comma = false
int[] x = new int[] { 1,2,3,4,5 };

csharp_space_before_comma

재산 묘사
옵션 이름 csharp_space_before_comma
적용 가능한 언어 C#
옵션 값 true 쉼표 앞에 공백 삽입
false 쉼표 앞의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_comma = true
int[] x = new int[] { 1 , 2 , 3 , 4 , 5 };

// csharp_space_before_comma = false
int[] x = new int[] { 1, 2, 3, 4, 5 };

csharp_space_after_dot

재산 묘사
옵션 이름 csharp_space_after_dot
적용 가능한 언어 C#
옵션 값 true 점 뒤에 공백 삽입
false 점 뒤의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_after_dot = true
this. Goo();

// csharp_space_after_dot = false
this.Goo();

csharp_space_before_dot

재산 묘사
옵션 이름 csharp_space_before_dot
적용 가능한 언어 C#
옵션 값 true 점 앞에 공백 삽입
false 점 앞의 공간 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_dot = true
this .Goo();

// csharp_space_before_dot = false
this.Goo();

csharp_space_after_semicolon_in_for_statement

재산 묘사
옵션 이름 csharp_space_after_semicolon_in_for_statement
적용 가능한 언어 C#
옵션 값 true for 문의 각 세미콜론 뒤에 공백 삽입
false for 문의 각 세미콜론 뒤 공백 제거
기본 옵션 값 true

코드 예제:

// csharp_space_after_semicolon_in_for_statement = true
for (int i = 0; i < x.Length; i++)

// csharp_space_after_semicolon_in_for_statement = false
for (int i = 0;i < x.Length;i++)

csharp_space_before_semicolon_in_for_statement

재산 묘사
옵션 이름 csharp_space_before_semicolon_in_for_statement
적용 가능한 언어 C#
옵션 값 true for 문의 각 세미콜론 앞에 공백 삽입
false for 문의 각 세미콜론 앞에 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_semicolon_in_for_statement = true
for (int i = 0 ; i < x.Length ; i++)

// csharp_space_before_semicolon_in_for_statement = false
for (int i = 0; i < x.Length; i++)

csharp_space_around_declaration_statements

재산 묘사
옵션 이름 csharp_space_around_declaration_statements
적용 가능한 언어 C#
옵션 값 ignore 선언 문에서 추가 공백 문자를 제거하지 마세요.
false 선언 문에서 추가 공백 문자 제거
기본 옵션 값 false

코드 예제:

// csharp_space_around_declaration_statements = ignore
int    x    =    0   ;

// csharp_space_around_declaration_statements = false
int x = 0;

csharp_space_before_open_square_brackets

재산 묘사
옵션 이름 csharp_space_before_open_square_brackets
적용 가능한 언어 C#
옵션 값 true 대괄호 [ 열기 전에 공백 삽입
false 대괄호 [ 열기 전에 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_before_open_square_brackets = true
int [] numbers = new int [] { 1, 2, 3, 4, 5 };

// csharp_space_before_open_square_brackets = false
int[] numbers = new int[] { 1, 2, 3, 4, 5 };

csharp_space_between_empty_square_brackets

재산 묘사
옵션 이름 csharp_space_between_empty_square_brackets
적용 가능한 언어 C#
옵션 값 true 빈 대괄호 [ ] 사이에 공백 삽입
false 빈 대괄호 [] 사이의 공백 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_empty_square_brackets = true
int[ ] numbers = new int[ ] { 1, 2, 3, 4, 5 };

// csharp_space_between_empty_square_brackets = false
int[] numbers = new int[] { 1, 2, 3, 4, 5 };

csharp_space_between_square_brackets

재산 묘사
옵션 이름 csharp_space_between_square_brackets
적용 가능한 언어 C#
옵션 값 true 비어있지 않은 대괄호 [ 0 ] 공백 문자 삽입
false 비어있지 않은 대괄호 [0] 공백 문자 제거
기본 옵션 값 false

코드 예제:

// csharp_space_between_square_brackets = true
int index = numbers[ 0 ];

// csharp_space_between_square_brackets = false
int index = numbers[0];

래핑 옵션

줄 바꿈 서식 옵션은 문 및 코드 블록에 대해 한 줄과 별도의 줄을 사용하는 것과 관련이 있습니다.

예제 .editorconfig 파일:

#  CSharp formatting rules:
[*.cs]
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

csharp_preserve_single_line_statements

재산 묘사
옵션 이름 csharp_preserve_single_line_statements
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 문과 멤버 선언을 같은 줄에 둡니다.
false 문 및 멤버 선언을 다른 줄에 둡니다.
기본 옵션 값 true

코드 예제:

//csharp_preserve_single_line_statements = true
int i = 0; string name = "John";

//csharp_preserve_single_line_statements = false
int i = 0;
string name = "John";

csharp_preserve_single_line_blocks

재산 묘사
옵션 이름 csharp_preserve_single_line_blocks
적용 가능한 언어 C#
소개 버전 Visual Studio 2017
옵션 값 true 코드 블록을 한 줄에 남겨 둡니다.
false 코드 블록을 별도의 줄에 둡니다.
기본 옵션 값 true

코드 예제:

//csharp_preserve_single_line_blocks = true
public int Foo { get; set; }

//csharp_preserve_single_line_blocks = false
public int MyProperty
{
    get; set;
}

참고 항목