using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
namespace RandomWS
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string[] GenerateRandomColourArray(int numberOfRandomColours)
{
string[] colourPalette = { "Red", "Blue", "White", "Black", "Green", "Yellow", "Purple", "Pink", "Brown", "Grey", "Orange", "Cyan", "Magenta" };
Random random = new Random();
string[] arr = new string[numberOfRandomColours];
for (int j = 0; j < numberOfRandomColours; j++)
{
int i = random.Next(0, 13);
arr[j]= colourPalette[i];
}
return arr;
}
}
}
用WebService实现从指定数组中选择出任意个元素
最新推荐文章于 2021-02-21 16:32:12 发布