动态生成的Web服务的数组 [英] Dynamically build an array for web service

查看:131
本文介绍了动态生成的Web服务的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#和asp.net查询Web服务。

用户将进入客人的数量,然后我需要补充的是
 客人到Web服务呼叫号码。手动创建客人喜欢这个工作。

  //用于搜索创建房间布局客户成人=新客户();
adult.Id = 1;
adult.Title =先生;
adult.Firstname =测试;
adult.Surname =测试;客户adult2 =新客户();
adult2.Id = 2;
adult2.Title =先生;
adult2.Firstname =测试;
adult2.Surname =测试;游客[] =成人新访客[] {成人,adult2};

用户选择在我的网站的搜索成人人数
 页,不知成年人的数目,并希望能够动态地添加它们到web服务调用。我会recieving成年人像这样数量

  INT numberofguests = Convert.ToInt32(search.Guest);

我曾尝试做这件事的许多方面,但不能让它开始工作。


解决方案

 列表<家庭>客人=新的List<家庭>();
的for(int i = 0; I< numberOfGuests;我++)
{
  guests.Add(新客户()
  {
    标题=先生,
    名字=测试,
  });
}
返回guests.ToArray();

I'm using C# and asp.net to query a web service.

The user will enter the number of guests and then I need to add that number of guests to the web service call. Creating the guests manually like this works.

// Create room layout for searching

Guest adult = new Guest();
adult.Id = 1;
adult.Title = "Mr";
adult.Firstname = "Test";
adult.Surname = "Test";

Guest adult2 = new Guest();
adult2.Id = 2;
adult2.Title = "Mr";
adult2.Firstname = "Test";
adult2.Surname = "Test";

Guest[] adults = new Guest[] { adult,adult2 };

The user chooses the number of adults on my sites search page, I do not know the number of adults and want to be able to add them dynamically to the web service call. I will be recieving the number of adults like this

int numberofguests = Convert.ToInt32(search.Guest);

I have tried numerous ways of doing it, but can't get it to work

解决方案

List<Guest> guests = new List<Guest>();
for(int i=0; i<numberOfGuests; i++)
{
  guests.Add(new Guest()
  {
    Title = "Mr",
    Firstname = "Test",
  });
}
return guests.ToArray();

这篇关于动态生成的Web服务的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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