私はこのようなことをやろうとします:
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。質問は関連していますが、どちらも重複しています。