Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to simplify this code?
Message
 
 
To
03/09/2013 14:59:14
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01581943
Message ID:
01600840
Views:
57
>Could you reformat it into a switch statement?
>
>Bill
>

How about this case - is there a way to simplify? (In VFP it's case expression):
 Boolean isRedemptionValid = row.Field<Boolean>("IsRedemptionValid"),
                        isDateValid = row.Field<Boolean>("IsDateValid"),
                        isTimeValid = row.Field<Boolean>("IsTimeValid"),
                        isDowValid = row.Field<Boolean>("IsDowValid");

                    if (isRedemptionValid && isDateValid && isTimeValid && isDowValid)
                        {
                            availability = "Available for Redemption";
                        }
                    else
                        if (!isRedemptionValid)
                        {
                            availability = "Not enough number of uses";
                        }
                        else
                            if (!isDateValid)
                            {
                                availability = "Not available in the date range";
                            }
                            else
                                if (!isTimeValid)
                                {
                                    availability = "Not available in the time range";
                                }
                                else
                                {
                                    availability = "Not available on that day of the week";
                                }
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform