类错误中未定义的方法

时间:2016-11-07 05:23:02

标签: c# class

我试图在一个单独的类中使用一个方法,并且它正在重新划线

StringMethods does not contain definition for ParseCsvString etc

这是我现在正在构建的代码的源代码....

public class Employee
{
    public static Employee Parse(string stringValue)
    {
      string[] words;
      Employee employee = new Employee();

      words = StringMethods.ParseCsvString(stringValue.Trim());
      employee.ID = Int32.Parse(words[0]);
      employee.Name = words[1];
      employee.HireDate = Date.Parse(words[2]);
      employee.Rate = double.Parse(words[3]);
      employee.Hours = Double.Parse(words[4]);

      return employee;
    }
}

以下是定义解析方法的单独类的代码......

public class StringMethods
{
    public static string[] ParseCsvString(string stringValue)
    {
      int      i = 0;
      string[] words = null;
      Regex    regex = new Regex(@"""[^""\r\n]*""|'[^'\r\n]*'|[^,\r\n]+");
      Match    matchResults = null;

      if (stringValue!=null)
      {
        stringValue = stringValue.Trim();
        matchResults = regex.Match(stringValue);
        while (matchResults.Success) 
        {
          i++;
          matchResults = matchResults.NextMatch();
        }
        words        = new string[i];
        matchResults = regex.Match(stringValue);
        i = 0;
        for (i=0; i<words.Length; i++) 
        {
          words[i]     = matchResults.Value.Replace("\"","");
          matchResults = matchResults.NextMatch();
        }
      }
      return words;
    }
}

当我打电话给words = StringMethods.ParseCsvString(stringValue.Trim())时,它说没有定义。但它是和DLL是最新的。任何想法如何解决这个问题?

0 个答案:

没有答案