// A single blog entry
public class BlogEntry
{
public string ID;
public string Title;
public string Entry;
public DateTime Date;
public int UserID;
// Load an entry based on ID
public BlogEntry(int EntryID)
{
DataClassesDataContext db = new DataClassesDataContext();
var q = (from Blog in db.tblBlogEntries where Blog.ID == EntryID select Blog).Single();
// Fill data
this.ID = EntryID;
this.Title = q.title;
this.Entry = q.entry;
this.Date = (DateTime)q.date;
this.UserID = (int)q.userID;
}
}
this.ID = EntryID is throwing the error:
Cannot implicity turn type ‘string’ to
‘int’
I’m baffled, because they are both defined as integers, quite explicitly!
In your class definition, ID is defined as String
and you are trying to assing an
int.That’s why.