0

I am trying to build a code but while using switch case this is showing an error like **A Constant value expected ** in my switch case. can not we write like this case "CRLR'" + CaseDetails.registerno + "' of '" +CaseDetails.year+"'- R ": CaseDetails.details = tabledata.LastChild.PreviousSibling.InnerText.Trim();in switch case? If no please let me know how to get non constant value in switch. this is my code

    public CaseDetailsParser ParseCaseDetails(HtmlDocument htdocment)
    {
        CaseDetailsParser detailsParser = new CaseDetailsParser();
        if (htdocment.DocumentNode.InnerText.Contains("THIS CASE IS NOT REGISTERED"))
        {
            return detailsParser;
        }
        var data = htdocment.DocumentNode.SelectNodes("//table").Where(x => x.Attributes.Contains("bgcolor") && x.Attributes["bgcolor"].Value == "Azure");
        foreach (var value in data)
        {
            var rowvalue = value.ChildNodes;
            foreach (var tabledata in rowvalue)
            {
                var tdatas = tabledata.ChildNodes;
                if (tabledata.Name != "#text")
                    switch (tabledata.FirstChild.NextSibling.InnerText.Trim())
                    {
                        case "Date of query :": CaseDetails.dateOfQuery = tabledata.LastChild.PreviousSibling.InnerText.Trim();
                            break;
                        case "Time :": CaseDetails.Time = tabledata.LastChild.PreviousSibling.InnerText.Trim();
                            break;
                        case "CRLR'" + CaseDetails.registerno + "' of '" +CaseDetails.year+"'- R ": CaseDetails.details = tabledata.LastChild.PreviousSibling.InnerText.Trim();
                        //    break;


                    }
            }
vashista vasi
  • 41
  • 1
  • 6

0 Answers0