我有一個非常簡單的類,不會編譯,因爲在構造函數中的默認參數。該語言是C#,該類將用於Unity3d遊戲中。所以這個編譯錯誤是發生在統一的 「IDE」簡單的編譯錯誤在類的構造函數
編譯錯誤:
Assets/Utilities/GenericClasses.cs(30,94): error CS1736: The expression being assigned to optional parameter `nName' must be a constant or default value
public class Element {
public static readonly string NULL_NAME = "___NULL_NAME___";
public enum elementType {E_ELEMENT, E_MODEL, E_VIEW, E_SUPER, E_ARC};
private string name;
private elementType type;
// line 30 is below
public Element(elementType nType=elementType.E_ELEMENT, string nName=NULL_NAME) {
type = nType;
name = nName;
}
}
我在做什麼錯?