Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible to simplify this code?
Message
De
10/09/2013 12:26:29
 
 
À
10/09/2013 10:32:23
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01581943
Message ID:
01582724
Vues:
40
>>Speaking of Action I could have used an Action< T, T >
>>
>>		static Dictionary <string, Action<GroupMember, MKVP>> Actions = new Dictionary<string,Action<GroupMember,MKVP>>()
>>		{	 {"PRI_KEY", ChangePrimaryKey}
>>			,{"FIRST", ChangeFirstName}
>>			,{"LAST", ChangeLastName}
>>			,{"GSTNO", ChangeGuestNo}
>>			,{"NOTES", ChangeNotes}
>>		};
>>
>Even better :-}

It's a matter of taste

If you pull it out of the dictionary to assign it to a variable, I prefer declaring the delegate with a meaningful name
In that case you don't have to repeat the definition
Action<GroupMember, MKVP>>  action;
If you access the dictionary directly - then perhaps yes
dict[someString](groupmember, mkvp);
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform