Return Anonymous Type from a function

前端 未结 6 998
庸人自扰
庸人自扰 2020-12-16 11:05

Can I use an anonymous type as a return type in a Function, and then stuff that returned value into an array or collection of some sort whilst also adding an additional fiel

6条回答
  •  执笔经年
    2020-12-16 12:03

    Use object, not var. You'll have to use reflection to access the properties outside the scope of the anonymous type though.

    i.e.

    private object GetRowGroups(string columnName) 
    ...
    var RowGroupList = new List();
    ...
    
        

    提交回复
    热议问题