effekt26
Feb 22nd, 2007, 03:37 AM
Ok, i have the following code, but im having trouble returning the array of BlogEntry objects....
BlogEntry[] _blogEntries = new BlogEntry[_totalEntries];
for (int i = 0; i <= _totalEntries; i++) {
BlogEntry _entry = new BlogEntry();
_entry.Id = (int)dsBlogPosts.Tables[0].Rows[i]["entry_id"];
_entry.Title = (string)dsBlogPosts.Tables[0].Rows[i]["entry_title"];
_entry.Post = (string)dsBlogPosts.Tables[0].Rows[i]["entry_post"];
_entry.PostDescription = (string)dsBlogPosts.Tables[0].Rows[i]["entry_post_desc"];
_entry.PostDate = (DateTime)dsBlogPosts.Tables[0].Rows[i]["entry_post_date"];
_entry.Ip = (string)dsBlogPosts.Tables[0].Rows[i]["entry_ip"];
_entry.CategoryName = (string)dsBlogPosts.Tables[0].Rows[i]["category_name"];
_entry.Author = (string)dsBlogPosts.Tables[0].Rows[i]["author_name"];
_entry.AuthorEmail = (string)dsBlogPosts.Tables[0].Rows[i]["author_email"];
_blogEntries[i] = _entry;
}
return _blogEntries;
i get an error on the 'return _blogEntries;' line. cannot convert type BlogEntry[] to BlogEntry is the error message...
if i do a 'return _blogEntries[];' i get a Expecting value...but a 'return _blogEntries[0];' works fine...will this return the first dimension of the array...or the first key...
whats the correct return syntax??
Thanks, Justin
BlogEntry[] _blogEntries = new BlogEntry[_totalEntries];
for (int i = 0; i <= _totalEntries; i++) {
BlogEntry _entry = new BlogEntry();
_entry.Id = (int)dsBlogPosts.Tables[0].Rows[i]["entry_id"];
_entry.Title = (string)dsBlogPosts.Tables[0].Rows[i]["entry_title"];
_entry.Post = (string)dsBlogPosts.Tables[0].Rows[i]["entry_post"];
_entry.PostDescription = (string)dsBlogPosts.Tables[0].Rows[i]["entry_post_desc"];
_entry.PostDate = (DateTime)dsBlogPosts.Tables[0].Rows[i]["entry_post_date"];
_entry.Ip = (string)dsBlogPosts.Tables[0].Rows[i]["entry_ip"];
_entry.CategoryName = (string)dsBlogPosts.Tables[0].Rows[i]["category_name"];
_entry.Author = (string)dsBlogPosts.Tables[0].Rows[i]["author_name"];
_entry.AuthorEmail = (string)dsBlogPosts.Tables[0].Rows[i]["author_email"];
_blogEntries[i] = _entry;
}
return _blogEntries;
i get an error on the 'return _blogEntries;' line. cannot convert type BlogEntry[] to BlogEntry is the error message...
if i do a 'return _blogEntries[];' i get a Expecting value...but a 'return _blogEntries[0];' works fine...will this return the first dimension of the array...or the first key...
whats the correct return syntax??
Thanks, Justin