Does not contain a definition or extension method
source link: https://www.codesd.com/item/does-not-contain-a-definition-or-extension-method.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Does not contain a 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:
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 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 existf.DocumentTypeId
does not exist.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.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK