我们如何在C#中构造关联数组 [英] How Can we construct Associate Array in C#
本文介绍了我们如何在C#中构造关联数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用MVC4,我需要使用以 PHP语言创建的消费服务。
该服务需要类型为关联数组的参数。我知道Associate Array只有PHP。
PHP中的Associte Array对象
Hi all,
I am using MVC4, I need to Consume Service which is Created in PHP language.
That Service needs Parameters as of type Associative Array. I know Associate Array is in only PHP.
Associte Array object in PHP
var params = {
user_auth:{
user_name:user_name,
password:password,
encryption:'PLAIN'
},
application: 'SugarCRM RestAPI Example'
};
如何构建C#中的上述等效关联数组对象?
i需要构造它在C#中,然后作为服务的参数发送。
我怎样才能达到这个目标?
请帮我一些示例代码或分享您的想法?
谢谢
How can i construct above Equivalent Associative Array object in C# ?
i need to construct it in C# , and then send as parameter for Service.
How can I achieve this ?
Please Help me with some sample Code or share your ideas ?
Thank You
推荐答案
在C#中,这在技术上不是一个数组。数组是具有相同类型的对象的集合。你有什么,是一个对象,C#允许你创建匿名对象。像这样:
In C#, that is technically not an array. An array is a collection of objects with the same type. What you have there, is an object and C# allows you to create anonymous objects. Like so:
var p = new {
user_auth = new {
user_name = "",
password = "",
encryption = "PLAIN"
},
application = "SugarCRM RestAPI Example"
};
// use it elsewhere like so:
if(p.user_auth.user_name == ""){
}
这篇关于我们如何在C#中构造关联数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文