如何在Visual Basic(ASP)中创建以下关联数组数组?如何在VB.NET中创建类似于PHP的关联数组?
array(
array('customer' => 'khl', 'city' => 'bune'),
array('customer' => 'Kla', 'value' => 'Swa')
)
如何在Visual Basic(ASP)中创建以下关联数组数组?如何在VB.NET中创建类似于PHP的关联数组?
array(
array('customer' => 'khl', 'city' => 'bune'),
array('customer' => 'Kla', 'value' => 'Swa')
)
下面是做这件事:
var array = new List<Dictionary<string,string>>();
array.Add(new Dictionary<string,string>());
array[0].Add("customer", "khl");
array[0].Add("city", "bune");
array.Add(new Dictionary<string,string>());
array[1].Add("customer", "Kla");
array[1].Add("city", "Swa");
可以让这个简单的通过使您的详细资料为结构,如果你知道的参数是一组形式:
struct Customer
{
public string Name;
public string City;
}
var array = new List<Customer>();
array.Add(new Customer { Name = "khl", City = "bune" });
array.Add(new Customer { Name = "Kla", City = "Swa" });
我不能在soap header中设置它,我使用php webservice,在参数中有嵌套数组。 – user795562
你没有指定ASP.NET(或者你使用的是什么语言),所以我只是跟你给了我什么。如果你试图从序列化表单中解析出来,你需要编写一个解析器。 – Polynomial
是的,其实我使用vb.net,我有php webservice需要嵌套数组作为参数。所以上面的代码是可以的。但是当我发送到PHP服务返回内部错误。 – user795562
.NET并不是一门真正的语言,所以你指的是什么语言? – halfdan
我的意思是.net平台语言,如c#,vb – user795562
是的,您使用的是哪一种? –