Solved

C# IList conversion from VB

Posted on 2011-09-16
5
370 Views
Last Modified: 2012-05-12
I am trying to conver my vb code below to C#. But I get the error "Using the gerneric type system.collections.generic.IList<T> requires 1 type arguments" where the iList is declared in the declaration.

Would be grateful for any help.

Thanks

Public Function CreateGrid(ByVal id As String,
                   ByVal allowGrouping As Boolean,
                   ByVal allowFiltering As Boolean,
                   ByVal showFooter As Boolean,
                   ByVal allowAddingRecords As Boolean,
                   ByVal autoGenerateColumns As Boolean,
                   ByVal pageSize As Integer,
                   ByVal showHeader As Boolean,
                   ByVal dataSource As IList) As Grid

C# Conversion.......

public Grid CreateGrid(string id, bool allowGrouping, bool allowFiltering, bool showFooter, bool allowAddingRecords, bool autoGenerateColumns, int pageSize, bool showHeader, IList dataSource)
0
Comment
Question by:Soluga
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 36549221
This is it without knowing your data type:

public Grid CreateGrid(string id, bool allowGrouping, bool allowFiltering, bool showFooter, bool allowAddingRecords, bool autoGenerateColumns, int pageSize, bool showHeader, IList<DATATYPEHERE> dataSource) 

Open in new window


This is it assuming your data type:

public Grid CreateGrid(string id, bool allowGrouping, bool allowFiltering, bool showFooter, bool allowAddingRecords, bool autoGenerateColumns, int pageSize, bool showHeader, IList<ObjectDataSource> dataSource) 

Open in new window

0
 
LVL 1

Author Comment

by:Soluga
ID: 36549234
My datasource is a generic list!
0
 
LVL 1

Author Comment

by:Soluga
ID: 36549254
Would this work...

using System.Collections;

          public Grid CreateGrid(string id, bool allowGrouping, bool allowFiltering, bool showFooter, bool allowAddingRecords, bool autoGenerateColumns, int pageSize, bool showHeader, IList<ICollection> dataSource)
0
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 36549261
Ok, sorry for the misunderstanding... to pass a generic list as a parameter you can do this:

public Grid CreateGrid<T>(string id, bool allowGrouping, bool allowFiltering, bool showFooter, bool allowAddingRecords, bool autoGenerateColumns, int pageSize, bool showHeader, IList<T> dataSource)

Open in new window

0
 
LVL 1

Author Closing Comment

by:Soluga
ID: 36549440
OK,
Thats great thanks.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question