मैं ऐसा कुछ करने की कोशिश करता हूं:
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। प्रश्न संबंधित हैं, लेकिन न तो दूसरे का डुप्लिकेट है।