Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace linkTest
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Thing> listOfThings = new List<Thing>();
- listOfThings.Add(new Thing("thing1","data for thing one"));
- listOfThings.Add(new Thing("thing2", "data for thing two"));
- var myFavorite = from stuff in listOfThings
- where
- stuff.Name == "thing1"
- select new
- {
- stuff.Name,
- stuff.Data
- };
- var foo = myFavorite.First();
- if(foo != null)
- Console.WriteLine(foo);
- Console.ReadLine();
- }
- }
- class Thing
- {
- public string Name { get; set; }
- public string Data { get; set; }
- public Thing(string name,string data)
- {
- this.Name = name;
- this.Data = data;
- }
- }
- }
Add Comment
Please, Sign In to add comment