zoukankan      html  css  js  c++  java
  • return anonymous type from method.

    原文 http://tomasp.net/blog/cannot-return-anonymous-type-from-method.aspx
    TESTCODE:
     1         private void button1_Click(object sender, EventArgs e)
     2         {
     3             IEnumerable list = GetAA();
     4             foreach (var v in list)
     5             { 
     6                 var t = Cast(v,new {N1=0,N2=0,N3=0});
     7                 MessageBox.Show(t.N1.ToString());
     8             }
     9         }
    10 
    11         T Cast<T>(object obj, T type)
    12         {
    13             return (T)obj;
    14         }
    15 
    16         public IEnumerable GetAA()
    17         {
    18             var list = from i in new int[] { 1234567 }
    19                        select new { N1 = i, N2 = i, N3 = i };
    20             return list;
    21         }



    ----------------------------------- http://www.cnblogs.com/rock_chen/
  • 相关阅读:
    Vue部分知识
    JAVA基础之Map接口
    浏览器渲染机制及五大浏览器、四大内核
    WebPack
    Gulp
    GC垃圾回收机制
    Git操作(及操作github)
    Git、Github和GitLab的区别及与SVN的比较
    Node.js介绍
    JAVA基础之Set接口
  • 原文地址:https://www.cnblogs.com/rock_chen/p/1121082.html
Copyright © 2011-2022 走看看