Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is it possible to simplify this code?
Message
From
03/09/2013 14:58:59
 
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:
01581946
Views:
99
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>In VFP I would use CASE expression. Is there any way to simplify this code?
>
>
>     if (String.Equals(mkvp.Key, "PRI_KEY", StringComparison.OrdinalIgnoreCase))
>                           groupMember.PrimaryKey = Convert.ToInt32(mkvp.Value);
>
>                        if (String.Equals(mkvp.Key, "FIRST", StringComparison.OrdinalIgnoreCase))
>                           groupMember.FirstName = mkvp.Value;
>
>                        if (String.Equals(mkvp.Key, "LAST", StringComparison.OrdinalIgnoreCase))
>                           groupMember.LastName = mkvp.Value;
>
>                        if (String.Equals(mkvp.Key, "GstNo", StringComparison.OrdinalIgnoreCase))
>                           groupMember.GuestNo = Convert.ToInt64(mkvp.Value);
>
>                        if (String.Equals(mkvp.Key, "Notes", StringComparison.OrdinalIgnoreCase))
>                           groupMember.Notes = mkvp.Value;
Yes, use a switch/case
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform