c# - How to get IEnumerable to have the right type -
so have programme supposed take bunch of values, store them in "projects" object within function, called block of code:
public ienumerable<projectall> getallprojects() { var project = pullallprojects(); homecoming project; }
the error @ homecoming project, , reads:
error 1 cannot implicitly convert type 'projectsapp.models.project' 'system.collections.generic.ienumerable<projectsapp.models.projectall>'. explicit conversion exists (are missing cast?)
so, found on stackoverflow: an explicit conversion exists (are missing cast?)
but when followed instructions...
ienumerable <project> project = new project(); while (rdr.read()) { project.id = (int)rdr["project_id"]; project.name = (string)rdr["project_name"]; project.title = (string)rdr["project_title"]; project.network = (int)rdr["main_network"]; project.start = (datetime)rdr["project_start"]; } homecoming project;
i got error on each of variables(id, name, ect).
error 4 'system.collections.generic.ienumerable<projectsapp.models.project>' not contain definition 'name' , no extension method 'name' accepting first argument of type 'system.collections.generic.ienumerable<projectsapp.models.project>' found (are missing using directive or assembly reference?)
it seemed work person @ stackoverflow link, what's different way i'm doing it?
let me know if need add together more information, in advance!
ienumerable<project>
cannot assigned project
. right way that:
public ienumrable<project> pullallprojects { . . . var projects = new list<project>(); while (rdr.read()) { projects.add(new project { id = (int)rdr["project_id"]; name = (string)rdr["project_name"]; title = (string)rdr["project_title"]; network = (int)rdr["main_network"]; start = (datetime)rdr["project_start"]; }); } homecoming projects; }
c# ienumerable
No comments:
Post a Comment