Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Dynamic;
- using System.Linq;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- dynamic x = GetAThing();
- Console.WriteLine(x.Title);
- var myFoos = new[]
- {
- new Foo
- {
- Id = 1,
- Bar = "one",
- Baz = "eno"
- },
- new Foo
- {
- Id = 2,
- Bar = "two",
- Baz = "owt"
- }
- };
- var myNewFoos = myFoos.Select(y => new {y.Bar, y.Baz});
- foreach (var cur in myNewFoos)
- {
- Console.WriteLine(cur.Bar, cur.Baz);
- }
- Console.ReadKey();
- }
- public class Foo
- {
- public int Id { get; set; }
- public string Bar { get; set; }
- public string Baz { get; set; }
- }
- static dynamic GetAThing()
- {
- dynamic foo = new ExpandoObject();
- foo.Title = "Foo";
- return foo;
- }
- static void ProjectFoos(IEnumerable<Foo> foos)
- {
- var myNewFoos = foos.Select(y => new { y.Bar, y.Baz });
- //return myNewFoos;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement