[英]Does not contain definition or extension method
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: 现在我试图在我的其他类中获取Documenttypeid的值,如下所示:
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. 谢谢。
The problem is with f.DocumentTypeId
. 问题出在f.DocumentTypeId
。
Assuming it's also a JobFile
, it be f.DocumentTypeID
(note the ID not Id ). 假设它也是一个JobFile
,它是f.DocumentTypeID
(注意ID不是Id )。 C# is case sensitive. C#区分大小写。 Also, there is only a get
property accessor, not a set
. 此外,只有一个get
属性访问器,而不是一set
。
If f
is some other type, show us the code. 如果f
是其他类型,请向我们展示代码。
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: 它可能只是以下两件事之一:
f
does not exist f
不存在 f.DocumentTypeId
does not exist. f.DocumentTypeId
不存在。 jf.DocumentTypeID
does not exist jf.DocumentTypeID
不存在 Honestly, I would check to make sure that f.DocumentTypeId
is not supposed to be f.DocumentTypeID
. 老实说,我会检查以确保f.DocumentTypeId
不应该是f.DocumentTypeID
。 C# is picky about things like that, and a small mistake like that would cause the error that you're receiving. C#对此类事情很挑剔,像这样的小错误会导致你收到的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.