Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IEnumerable cannot be used with type arguments

Tags:

asp.net

linq

I would like to use a data list for showing the usernames and their comments and attachments for each comment below the user name.

I have a user control ReviewListfor showing the comments and efiles in that. But I have error in this line (s.tblDraft.Comments) and an error below:

The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments 

Please help. What is the problem?

private void Displayuser() {     var reviews =       (from s in _DataContext.tblSends        from u in _DataContext.Users         where (s.DraftId == _Draftid) && (s.ToEmailId == u.ID)        orderby u.Name        select new {     userid = u.ID,     username = u.Name,     comments =s.tblDraft.Comments,     w = s.tblDraft.Comments.SelectMany(q => q.CommentAttaches)  }).Distinct();      DataList1.DataSource = reviews;     DataList1.DataBind();      var theReview = reviews.Single();      DisplayReviews(theReview.comments, theReview.w); }  private void DisplayReviews(IEnumerable<Comment> comments,      IEnumerable<CommentAttach> w) {     ReviewList reviewList = (ReviewList)DataList1.FindControl("ReviewList1");     reviewList.Comments = comments;     reviewList.CommentAttachs = w;     reviewList.DataBind(); } 
like image 829
masoud Avatar asked Jan 20 '13 19:01

masoud


1 Answers

The type the compiler sees is System.Collections.IEnumerable which is the non generic IEnumerable. You imported that namespace, so this is the type the compiler thinks you're trying to use.

The type you're trying to use is System.Collections.Generic.IEnumerable<T>. Add an import of that namespace and things should compile.

like image 163
Joachim Isaksson Avatar answered Sep 20 '22 11:09

Joachim Isaksson