Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP inlist() in c#
Message
 
 
To
26/01/2013 06:36:12
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01320903
Message ID:
01564278
Views:
40
>>>Declaring the type for the generic in the function call also works:
closeDrawers.InList< short >(2, 4)
>>
>>Do you know if there is something similar to VFP Case statement in C# where we can analyze different conditions?
>>
>>Say,
>>
>>I just wrote this part:
>>
>>
>> if (startTime > defaultDate && endTime > defaultDate)
>>                                    {
>>                                        whereClause.AppendLine(" AND date_time between @StartTime and @EndTime");
>>                                        sqlCommand.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = startTime;
>>                                        sqlCommand.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime;
>>                                    }
>>
>>I need 2 more cases for only startTime defined or only endTime defined. If I will use if I again need to check both variables.
>>
>>Wondering if there is something in C# that makes this decision choice easier. I believe there is nothing in C# that is like VFP case where we can test various expressions - quick Google search also confirms it.
>
>The closest you can get is to use if/else if /else if/else
>
>
>
> if (startTime > defaultDate && endTime > defaultDate)
> {
>               whereClause.AppendLine(" AND date_time between @StartTime and @EndTime");
>                sqlCommand.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = startTime;
>                 sqlCommand.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime;
>  } 
>else     if (startTime > defaultDate && endTime > defaultDate)
> {
>               whereClause.AppendLine(" AND date_time between @StartTime and @EndTime");
>                sqlCommand.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = startTime;
>                 sqlCommand.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime;
>  } 
>
>else     if (startTime > defaultDate && endTime > defaultDate)
> {
>               whereClause.AppendLine(" AND date_time between @StartTime and @EndTime");
>                sqlCommand.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = startTime;
>                 sqlCommand.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime;
>  } 
>else   
> {
>               whereClause.AppendLine(" AND date_time between @StartTime and @EndTime");
>                sqlCommand.Parameters.Add("@StartTime", SqlDbType.DateTime).Value = startTime;
>                 sqlCommand.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime;
>  } 
>
>
>>

Yes, that's what I used - just wished there was something else in C# I can use.
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