Skip to content

Instantly share code, notes, and snippets.

@jamesmanning
Created March 7, 2012 22:09
Show Gist options
  • Select an option

  • Save jamesmanning/1996569 to your computer and use it in GitHub Desktop.

Select an option

Save jamesmanning/1996569 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
var dict = new Dictionary<string, object>
{
{ "123", 123 },
{ "17", "17" },
{ Math.PI.ToString(), Math.PI },
};
foreach (var pair in dict)
{
Console.WriteLine(pair);
}
var someString = String.Join(", ",
from pair in dict
where pair.Key.Length > 2
select String.Format("{0}={1}", pair.Key, pair.Value)
);
someString = String.Join(", ",
dict
.Where(pair => pair.Key.Length > 2)
.Select(pair => String.Format("{0}={1}", pair.Key, pair.Value))
);
Console.WriteLine(someString);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment