Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ITestInterface { };
- public class TestClass<T> : ITestInterface
- {
- public T member { get; set; }
- }
- public static class Util
- {
- public static ITestInterface Create<C>(C t)
- {
- return new TestClass<C> { member = t };
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var a = Util.Create(new
- {
- p1 = 100,
- p2 = "string"
- });
- var b = a as TestClass<Object>;
- // this will be "null" in this example
- // So, how can I convert back to its real type?
- // And get the "member" data
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement