C# 4.0 dynamics
Posted
by mehanik
on Stack Overflow
See other posts from Stack Overflow
or by mehanik
Published on 2010-04-13T14:34:00Z
Indexed on
2010/04/13
14:43 UTC
Read the original article
Hit count: 244
Hi. Code bellow is working well until I have class ClassSameAssembly in same assembly as class Program. But when I move class ClassSameAssembly to separate assembly I have runtime error. Is it posible to resolve it?
using System;
namespace ConsoleApplication2
{
public static class ClassSameAssembly
{
public static dynamic GetValues()
{
return new
{
Name = "Michael", Age = 20
};
}
}
internal class Program
{
private static void Main(string[] args)
{
var d = ClassSameAssembly.GetValues();
Console.WriteLine("{0} is {1} years old", d.Name, d.Age);
}
}
}
© Stack Overflow or respective owner