The C# code below is giving me error on the two lines beginning with case . The error is "A constant value is expected"
The VB.NET code below is working. I'm using this code as a sample for my real app written in C#.
I don't see the problem but that doesn't mean one isn't present. I used a couple of online code converters to double-check the syntax. Both are returning the same result, which gives the error.
ExportFormatType is an enum in a third-party library.
Any suggestions? Thanks!
public void ExportCrystalReport(string exportType, string filePath)
{
if (_CReportDoc.IsLoaded == true)
{
switch (exportType)
{
case ExportFormatType.PortableDocFormat.ToString(): // Or "PDF"
ExportTOFile(filePath, ExportFormatType.PortableDocFormat);
break;
case ExportFormatType.CharacterSeparatedValues.ToString(): // Or "CSV"
ExportTOFileCSV(filePath, ExportFormatType.CharacterSeparatedValues);
break;
}
}
Public Sub ExportCrystalReport(ByVal exportType As String, ByVal filePath As String)
If _CReportDoc.IsLoaded = True Then
Select Case exportType
Case ExportFormatType.PortableDocFormat.ToString 'Or "PDF"
ExportTOFile(filePath, ExportFormatType.PortableDocFormat)
Case ExportFormatType.CharacterSeparatedValues.ToString ' Or "CSV"
ExportTOFileCSV(filePath, ExportFormatType.CharacterSeparatedValues)