Why does the compiler only complain when a method is called in a switch statement for a constant value and why is it the error The type name 'A' does not exist in the type
?
CS0426 The type name 'A' does not exist in the type 'ClassificationIdentifiers.ClassificationIdentifiersChildren'
public static class ClassificationIdentifiers
{
public static class ClassificationIdentifiersChildren
{
public const string A = "A";
}
}
switch (classificationFileType)
{
case ClassificationIdentifiers.ClassificationIdentifiersChildren.A:
classification = ClassificationIdentifiers.ClassificationIdentifiersChildren.A;
break;
}
switch (classificationFileType)
{
case ClassificationIdentifiers.ClassificationIdentifiersChildren.A.ToLower():
classification = ClassificationIdentifiers.ClassificationIdentifiersChildren.A;
break;
}
I assume it has something to do with the errors below, "A".ToLower();
or case a.ToLower():
.
const string a = "A".ToLower();
switch (classificationFileType)
{
case a.ToLower():
classification = ClassificationIdentifiers.ClassificationIdentifiersChildren.A;
break;
}
CS0133 The expression being assigned to 'a' must be constant
CS0118 'a' is a variable but is used like a type