RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
C# 编码规范
  • 作者:zhaozj
  • 发表时间:2020-12-23 10:37
  • 来源:未知

先猜个谜再看吧

两只蚂蚁一起慢慢的爬着,忽然一只蚂蚁发现一个大大的梨子。(猜两个国家的名) 谜底在文章未

 

Technotes, HowTo Series

C# Coding Style Guide

Version 0.3by Mike Krüger icsharpcode.net

About the C# Coding Style Guide File Organization Indentation Comments Declarations Statements White Space Naming Conventions Programming Practices Code Examples

1. About the C# Coding Style Guide

This document may be read as a guide to writing robust and reliable programs. It focuses on programs written in C#, but many of the rules and principles are useful even if you write in another programming language.

2. File Organization

2.1 C# Sourcefiles

Keep your classes/files short, don't exceed 2000 LOC, divide your code up, make structures clearer. Put every class in a separate file and name the file like the class name (with .cs as extension of course). This convention makes things much easier.

2.2 Directory Layout

Create a directory for every namespace. (For MyProject.TestSuite.TestTier use MyProject/TestSuite/TestTier as the path, do not use the namespace name with dots.) This makes it easier to map namespaces to the directory layout.

3. Indentation

3.1 Wrapping Lines

When an expression will not fit on a single line, break it up according to these general principles:

Break after a comma. Break after an operator. Prefer higher-level breaks to lower-level breaks. Align the new line with the beginning of the expression at the same level on the previous line

Example of breaking up method calls: