不包含定义或扩展方法
当我尝试构建时出现下一个错误:
不包含定义或扩展方法
我有一个这样的类:
[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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误消息非常清楚地说明了问题所在。您正在尝试使用不存在的属性,并查看此行中如何发生错误:
它可能只是以下两种情况之一:
f
不存在f .DocumentTypeId
不存在。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:
It could only be one of two things:
f
does not existf.DocumentTypeId
does not exist.jf.DocumentTypeID
does not existHonestly, I would check to make sure that
f.DocumentTypeId
is not supposed to bef.DocumentTypeID
. C# is picky about things like that, and a small mistake like that would cause the error that you're receiving.问题出在
f.DocumentTypeId
上。假设它也是一个
JobFile
,则它是f.DocumentTypeID
(请注意 ID 而不是 Id)。C# 区分大小写。此外,只有
get
属性访问器,而不是set
。如果
f
是其他类型,请向我们展示代码。The problem is with
f.DocumentTypeId
.Assuming it's also a
JobFile
, it bef.DocumentTypeID
(note the ID not Id).C# is case sensitive. Also, there is only a
get
property accessor, not aset
.If
f
is some other type, show us the code.