不包含定义或扩展方法

发布于 2024-12-09 14:05:09 字数 1449 浏览 0 评论 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
}

有谁知道可能出了什么问题以及如何修复它? 谢谢。

I am getting next error when I try to build:

Does not contain definition or extension method

I have a class like this:

[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;
        }
    }

Now i am trying to get the value of Documenttypeid in my other class like so:

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

Does anyone know what could be wrong and how to fix it?
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰雪之触 2024-12-16 14:05:09

错误消息非常清楚地说明了问题所在。您正在尝试使用不存在的属性,并查看此行中如何发生错误:

f.DocumentTypeId = jf.DocumentTypeID;

它可能只是以下两种情况之一:

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

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

The error message is very clear about what's wrong. You're trying to use a property that doesn't exist, and seeing as how the error is occuring on this line:

f.DocumentTypeId = jf.DocumentTypeID;

It could only be one of two things:

  1. f does not exist
  2. f.DocumentTypeId does not exist.
  3. jf.DocumentTypeID does not exist

Honestly, I would check to make sure that f.DocumentTypeId is not supposed to be f.DocumentTypeID. C# is picky about things like that, and a small mistake like that would cause the error that you're receiving.

破晓 2024-12-16 14:05:09

问题出在 f.DocumentTypeId 上。

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


如果 f 是其他类型,请向我们展示代码。

The problem is with f.DocumentTypeId.

Assuming it's also a JobFile, it be f.DocumentTypeID (note the ID not Id).
C# is case sensitive. Also, there is only a get property accessor, not a set.


If f is some other type, show us the code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文