Rx
List<List<int>> l = new List<List<int>>(); 

l.Add(new List<int> { 1, 2, 3, 4, 5, 6}); 
l.Add(new List<int> { 4, 5, 6, 7, 8, 9 }); 
l.Add(new List<int> { 8, 9, 10, 11, 12, 13 }); 

var result =     (
            from    e in l 
            from    e2 in e 
            select    e2
        ).Distinct(); 

var yearsList =    from    e in Events 
                group    e by e.EventDate.Year into g 
                select    new 
        {
            Year    = g.Key,
            Events    = g 
        };

public event EventHandler MyEvent;  

protected void OnMyEvent(EventArgs e)  
{  
    EventHandler myEvent = MyEvent;  

    if (myEvent != null)  
    {  
        myEvent(this, e);  
    }  
} 

// Hot (non deferred) returns 1

var x = 1 

var xs = observable.Return(x);

x = 5;

observable.Subscribe(a);

// Cold (Deferred) returns 5

var x = 1 

var xs = observable.Defer( () => observable.Return(x););

x = 5;

observable.Subscribe(a);

void Main()
{
    XNamespace slashNamespace = "http://purl.org/rss/1.0/modules/slash/"; 
    XDocument rssFeed = XDocument.Load("http://weblogs.asp.net/scottgu/rss.aspx");

    var posts =    from item in rssFeed.Descendants("item")
                select new
                {
                    Title        = item.Element("title").Value,
                    Published    = DateTime.Parse(item.Element("pubDate").Value).ToString("dd/MM"),
                    CommentCount= Convert.ToInt32(item.Element(slashNamespace + "comments").Value),                       
                    Url            = item.Element("link").Value, 
                    Tags        =     (
                                        from    category in item.Elements("category")
                                        orderby    category.Value
                                        select    category.Value
                                    ).ToList()
                };
    //posts.Dump();                               
    string[] presidents = {"Ad", "Ar", "Bu", "Bu", "Ca", "Cl"};

    IEnumerable<string> sequence = presidents.Where((p, i) => (i & 1) == 1);

    sequence.Dump();
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License