2011-10-12 82 views
0

我得到一个错误,当我尝试建立:不含定义或扩展方法

不含定义或扩展方法

我有一类这样的:

[Serializable]  
public class JobFile 
{ 
    private FileInfo mFileInfo; 
    private string mJobNumber = string.Empty; 
    private string mBaseJobNumber = string.Empty; 
    private Guid mDocumentTytpeid = Guid.Empty; 

    public string DocumentTypeDescription 
    { 
     get 
     { 
      string description; 
      DocumentType DocType; 
      DocType = DocumentType.GetDocType(DocumentTypeCode);   
      if (DocType.Code == null)      
       description = "Unknown"; 
      else     
       description = DocType.Description;     
      return description; 
     } 
    } 

    public Guid DocumentTypeID 
    { 
     get 
     {    
      DocumentType DocType; 
      DocType = DocumentType.GetDocType(DocumentTypeCode); 
      if (DocType.Code == null) 
       mDocumentTytpeid = Guid.Empty;     
      else 
       mDocumentTytpeid = DocType.Id; 
      return mDocumentTytpeid; 
     } 
    } 

现在我试图让Documenttypeid的价值在我的其他类,像这样:

foreach (FileInfo fi in files) 
{ 
    JobFile jf = null; 
    jf = new JobFile(ref fi); 
    f.DocumentTypeId = jf.DocumentTypeID; //<-- error is here 
} 

有谁知道什么可能是错的,以及如何解决它? 谢谢。

+4

in'f.DocumentTypeId','f'的类型是什么? –

+2

循环中声明了“f”的位置?它不应该是'fi'吗? –

+0

请发布完整的错误文本。并且自己格式化你的代码,这是不可读的。 – abatishchev

回答

1

问题出在f.DocumentTypeId

假设它也是一个JobFile,它是f.DocumentTypeID(注意ID没有标识)。 C#区分大小写。此外,只有一个get属性访问器,而不是set


如果f是某种其他类型,请告诉我们代码。

+0

谢谢,f实际上是另一个班级,对不起,我没有把那部分放在那里,我试图简短。我将file.cs类(f)中的变量设置为在那里执行插入操作。 –

+0

如果'f'的类型是'JobFile',那么我的答案应该可以解决您的问题。 –

+0

它不是f类型的类型文件(Library.File.File f = new Library.File.File();) –

1

错误消息非常清楚什么是错的。你试图使用不存在的属性,并看到如何错误是在这条线存在的:

f.DocumentTypeId = jf.DocumentTypeID; 

它只能是两两件事之一:

  1. f做不存在
  2. f.DocumentTypeId不存在。
  3. jf.DocumentTypeID不存在

老实说,我会检查,以确保f.DocumentTypeId不应该是f.DocumentTypeID。 C#对这样的事情很挑剔,像这样的小错误会导致你收到的错误。

相关问题