创建一个动态的匿名类型变量 [英] Creating a dynamic anonymous types variables

查看:338
本文介绍了创建一个动态的匿名类型变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以创建一个匿名类型的变量,稍后添加更多的属性?

Can I create an anonymous type variable and later on add more Properties?

例如。
VAR X =新{名称=艾哈迈德}; ,并希望年龄补充呢?
我怎么能做到这一点。

E.g. var x = new { Name = "Ahmed" }; and want to add Age to it? how can I do this?

另外一个问题:我看到一些博客类型 AnonymousType 什么是这个类的名字空间?这里是上午例如 http://www.codeproject.com/KB/cs/AnonymousTypesInCSharp.aspx

Another question: i saw on some blogs a type AnonymousType what is the name space for this class? here is am example http://www.codeproject.com/KB/cs/AnonymousTypesInCSharp.aspx

推荐答案

第一个问题 - 你不能

First question - you can't.

第二个问题 - AnonymousType的类型创建文章的作者。您必须下载为他的项目中使用该类型的来源。

Second question - AnonymousType is the type the author of that article created. You have to download the source for his project to use that type.

这篇关于创建一个动态的匿名类型变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆