나는 다음과 같이 시도합니다.
public const List<String> METRICS = new List<String>()
{
SourceFile.LOC,
SourceFile.MCCABE,
SourceFile.NOM,
SourceFile.NOA,
SourceFile.FANOUT,
SourceFile.FANIN,
SourceFile.NOPAR,
SourceFile.NDC,
SourceFile.CALLS
};
그러나 불행히도 이것은 작동하지 않습니다.
FileStorer.METRICS' is of type 'System.Collections.Generic.List<string>'. A const field of a reference type other than string can only be initialized with null.
이 문제를 어떻게 해결할 수 있습니까?
ReadOnlyCollection됩니다. 질문은 관련이 있지만 둘 다 다른 질문과 중복되지 않습니다.