Вам не нужен LINQ, просто некоторые изящные дополнительные методы:
public static IDictionary<TKey, TValue> Sort<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
{
if(dictionary == null)
{
throw new ArgumentNullException("dictionary");
}
return new SortedDictionary<TKey, TValue>(dictionary);
}
public static IDictionary<TKey, TValue> Sort<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, IComparer<TKey> comparer)
{
if(dictionary == null)
{
throw new ArgumentNullException("dictionary");
}
if(comparer == null)
{
throw new ArgumentNullException("comparer");
}
return new SortedDictionary<TKey, TValue>(dictionary, comparer);
}
использование В качестве примера:
var dictionary = new Dictionary<int, string>
{
{ 1, "one" },
{ 2, "two" },
{ 0, "zero" }
};
foreach(var pair in dictionary.Sort())
{
Console.WriteLine("{0}: {1}", pair.Key, pair.Value);
}
// 0: zero
// 1: one
// 2: two
$('.myclass').bind("click", { Param1: "", Param2: 2 }, function(event){
alert(event.data.Param2);
});
you can use bind()
and send additional data to the event handler as event.data
this may not be the best method, but something i have done is to hyphen delineate the id attribute with other params, like id="101-red-420582"
which all three mean different things and can be easily broken down using the split()
function. not the best, per se, but i've done it and it works.