Coding PracticesAvoid putting multiple classes in a single file.A single file should contribute types to only a singlenamespace. Avoid having multiple namespaces in the same file.Avoid files with more than 500 lines (excludingmachine-generated code).
public class UDPSend { System.Net.Sockets.UdpClient UDP_C; //用於請求的UDP實列 //建構函式 public UDPSend(string host, int point) { CfgLoader xs = new CfgLoader(); try { UDP_C = new
Project Settings and Project StructureAlways build your projects with Warning Level 4 (see Figure E-1).Treat warnings as errors in the Release build (note that thisis not the default of Visual Studio). Although it is optional, this
Naming Conventions and StylesUse Pascal casing for type and method names and constants:public class SomeClass{ const int DefaultSize = 100; public SomeMethod( ) {}}Use camel casing for local variable names and methodarguments:int number;void
Framework-Specific GuidelinesMultithreadingUse synchronization domains.Avoid manual synchronization, because that often leads to deadlocks and raceconditions.Never call outside your synchronization domain.Manage asynchronous call completion on a
More Effective C# 第21條為:“讓重載方法儘可能清晰,最小化且完整”,第22條為:“定義方法後再重載操作符”。 具體文字我就不多描述了,“翠花,上代碼”: person類: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ExamNegateVirtualEvent{ public class Person :