-
Notifications
You must be signed in to change notification settings - Fork 25
Coding Style
MichaelO edited this page Apr 9, 2024
·
9 revisions
表明參考 (Indicate Reference)
- this: this.memberValue
public class Employee
{
private string _name;
private string _alias;
public Employee(string name, string alias)
{
this._name = name;
this._alias = alias;
}
}
存取修飾符 (Access Modifier)
- public: Lower Camel-Case
public int yourValue = 10;
- internal: Lower Camel-Case
internal int yourValue = 10;
- protected internal: _ + Lower Camel-Case (Start with "_")
protected internal int _yourValue = 10;
- protected: _ + Lower Camel-Case (Start with "_")
protected int _yourValue = 10;
- protected private: _ + Lower Camel-Case (Start with "_")
protected private int _yourValue = 10;
- private: _ + Lower Camel-Case (Start with "_")
private int _yourValue = 10;
- public: Upper Camel-Case
public void YourMethod() {}
- internal: Upper Camel-Case
internal void YourMethod() {}
- protected internal: Upper Camel-Case
protected internal void YourMethod() {}
- protected: Upper Camel-Case
protected void YourMethod() {}
- protected private: Upper Camel-Case
protected private void YourMethod() {}
- private: _ + Upper Camel-Case (Start with "_")
private void _YourMethod() {}
變量與方法的命名將會依照以上的存取修飾符規則進行套用。 |
---|
- class name: Upper Camel-Case
public class Student
{
public string name;
public int id;
}
- interface name: I + Upper Camel-Case (Start with I)
public interface INetTip {}
- public: Lower Camel-Case
public string name = "MyName";
public int id = 66;
- internal: Lower Camel-Case
internal string name = "MyName";
internal int id = 66;
- protected internal: _ + Lower Camel-Case (Start with "_")
protected internal string _name = "MyName";
protected internal int _id = 66;
- protected: _ + Lower Camel-Case (Start with "_")
protected string _name = "MyName";
protected int _id = 66;
- protected private: _ + Lower Camel-Case (Start with "_")
protected private string _name = "MyName";
protected private int _id = 66;
- private: _ + Lower Camel-Case (Start with "_")
private string _name = "MyName";
private int _id = 66;
- public: Lower Camel-Case
public static string name = "MyName";
public static int id = 66;
- internal: Lower Camel-Case
internal static string name = "MyName";
internal static int id = 66;
- protected internal: _ + Lower Camel-Case (Start with "_")
protected internal static string _name = "MyName";
protected internal static int _id = 66;
- protected: _ + Lower Camel-Case (Start with "_")
protected static string _name = "MyName";
protected static int _id = 66;
- protected private: _ + Lower Camel-Case (Start with "_")
protected private static string _name = "MyName";
protected private static int _id = 66;
- private: _ + Lower Camel-Case (Start with "_")
private static string _name = "MyName";
private static int _id = 66;
- public const: All-Upper Snake-Case
public const int MAX_COUNT = 64;
- internal const: All-Upper Snake-Case
internal const int MAX_COUNT = 64;
- protected internal: _ + All-Upper Snake-Case (Start with "_")
protected internal const int _MAX_COUNT = 64;
- protected: _ + All-Upper Snake-Case (Start with "_")
protected const int _MAX_COUNT = 64;
- protected private: _ + All-Upper Snake-Case (Start with "_")
protected private const int _MAX_COUNT = 64;
- private: _ + All-Upper Snake-Case (Start with "_")
private const int _MAX_COUNT = 64;
- public: Upper Camel-Case
public int Add(int a, int b)
{
return a + b;
}
- internal: Upper Camel-Case
internal int Add(int a, int b)
{
return a + b;
}
- protected internal: Upper Camel-Case
protected internal int Add(int a, int b)
{
return a + b;
}
- protected: Upper Camel-Case
protected int Add(int a, int b)
{
return a + b;
}
- protected private: Upper Camel-Case
protected private int Add(int a, int b)
{
return a + b;
}
- private: _ + Upper Camel-Case (Start with "_")
private int _Add(int a, int b)
{
return a + b;
}
- public: Upper Camel-Case
public static int Add(int a, int b)
{
return a + b;
}
- internal: Upper Camel-Case
internal static int Add(int a, int b)
{
return a + b;
}
- protected internal: Upper Camel-Case
protected internal static int Add(int a, int b)
{
return a + b;
}
- protected: Upper Camel-Case
protected static int Add(int a, int b)
{
return a + b;
}
- protected private: Upper Camel-Case
protected private static int Add(int a, int b)
{
return a + b;
}
- private: _ + Upper Camel-Case (Start with "_")
private static int _Add(int a, int b)
{
return a + b;
}
- enum name: Upper Camel-Case
public enum LoginStep
{
}
- enum value name: Upper Camel-Case
public enum SoundType
{
Sole,
SoundEffect
}
public enum PlayMode
{
EditorSimulateMode,
OfflineMode,
HostMode,
WebGLMode
}
- enum value name: All-Upper Snake-Case
public enum PatchStep
{
PATCH_PREPARE,
CHECK_VERSION,
UPDATE_MANIFEST,
BEGIN_DOWNLOAD,
DOWNLOAD_OVER,
PATCH_DONE
}
public enum NetStatus
{
CONNECTING,
CONNECTED,
CONNECTION_ERROR,
DISCONNECTED,
RECONNECTING
}