I have following enum definition
public enum UploaderType
{
BrandLogo = 0,
ReportingLogo = 1,
DocumentTemplate = 2,
MModalTemplate = 3,
}
I have a switch case in which i want to use this enum
void FileUploadExceptionHandler(FileUploadControl.FileUploadExceptionType exceptionType, FileUploadControl.UploaderType uploaderType)
{
switch (uploaderType)
{
case FileUploadControl.UploaderType.DocumentTemplate:
(this.Page as PageBase).SetMessage(string.Format(GetLocalResourceObject("FileExtensionError").ToString(), docIndentifier, formatAllowed(ucdocxUploadControl.SupportedFileTypes)), PageMessageType.ErrorMessage);
break;
case FileUploadControl.UploaderType.MModalTemplate:
(this.Page as PageBase).SetMessage(string.Format(GetLocalResourceObject("FileExtensionError").ToString(), docIndentifier, formatAllowed(ucampUploadControl.SupportedFileTypes)), PageMessageType.ErrorMessage);
break;
case FileUploadControl.UploaderType.MModalTemplate|FileUploadControl.UploaderType.DocumentTemplate:
(this.Page as PageBase).SetMessage(string.Format(GetLocalResourceObject("FileExtensionErrorForBoth").ToString(), formatAllowed(ucdocxUploadControl.SupportedFileTypes), formatAllowed(ucampUploadControl.SupportedFileTypes)), PageMessageType.ErrorMessage);
break;
}
}
I am trying to use combination of enum in third case but compiler complains The label ‘case 3:’ already occurs in this switch statement.
This enum is outside my control,so icannot use flags on it. Please suggest how to achieve this.
When i call it, i use
FileUploadExceptionHandler(FileUploadControl.FileUploadExceptionType.FileExtensionNotAllowed, FileUploadControl.UploaderType.DocumentTemplate | FileUploadControl.UploaderType.MModalTemplate);
You cannot do what you want. If you were able to modify the enum you would change it to this:
But since you can’t change it, there’s not much you can do.