简体   繁体   中英

C# send data from Windows Forms to WCF service

Can i send a List from windows form to a wcf service? I'm using wcf web service. I'm reading from a file in form and i want to send result to service.

StreamReader file = new StreamReader(File.OpenRead(ofd.FileName));
List<string> lines = new List<string>();
List<double> fileResult = new List<double>();
while(!file.EndOfStream)
{
    var line = file.ReadLine();
    lines.Add(line);

}
file.Close();

for (int i = 0; i < lines.Count; i++)                
{                
    fileResult.Add(Convert.ToDouble(lines[i]));                   
}

Yes, you can.

However, you'll want to send/receive it either as an IEnumerable<double> or a double[]

As for HOW (which you didn't ask) you may use this as a reference: http://www.codeproject.com/Articles/18789/A-Quick-and-Dirty-WCF-Service-and-Client-Using-WCF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM