1
嗨大家抱歉打扰你。我运行一个小博客,我只是试图创建一个web服务,允许输入单词并显示其意义。我最近在C#代码中自学成功,认为自己越来越好,但我遇到了一些困难。这是我目前的工作代码;CSV文件和Web服务
SORRY JUST NOTICED HAD COPY/PASTED WRONG CODE。更新的IT NOW
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace MyWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.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 class Table
{
private Dictionary<string, string> _regionTimeValues = new Dictionary<string, string>();
private String _words;
public Table(String words)
{
_words = words;
}
public void AddValue(string key, string value)
{
_wordsTimeValues.Add(key, value);
}
}
public class Program
{
static void Main(string[] args)
{
Dictionary<string, Table> tables = new Dictionary<string, Table>();
using (var reader = new StreamReader("Data.csv"))
{
// First line contains column names.
var columnNames = reader.ReadLine().Split(',');
for (int i = 1; i < columnNames.Length; ++i)
{
var columnName = columnNames[i];
tables.Add(columnName, new Table(columnName));
}
var line = reader.ReadLine();
while (line != null)
{
var columns = line.Split(',');
for (int i = 1; i < columns.Length; ++i)
{
var table = tables[columnNames[i]];
table.AddValue(columns[0], double.Parse(columns[i]));
}
line = reader.ReadLine();
}
}
}
}
}
}
我想,因为我也有类似的应用程序控制台应用程序中工作,但试图做它在一个web服务可以将其用作移动从一个应用程序代码到另一个简单已经把我拉我的头发。
究竟是什么? –
这甚至编译? getWords()中的'words'是什么?而'public string words()'似乎没有返回任何东西。 –
你期待这些方法做什么?正如他们目前的立场,应用程序不会编译,更不用说运行。 'words()'方法不返回值,'getWords()'引用一个尚未定义的变量。 – Kami