Generic return value

  • Thread starter Thread starter David Veeneman
  • Start date Start date
D

David Veeneman

I'm writing a custom Find() function on a collection class derived from
List<T>. The function will return an object of the type held in the
collection.

How do I specify the return type of the function? Thanks.
 
David,

You can just do:

public T Find()
{
}

This assumes that T is the generic type parameter declared on the class
level.

Hope this helps.
 
David Veeneman said:
I'm writing a custom Find() function on a collection class derived from
List<T>. The function will return an object of the type held in the
collection.

How do I specify the return type of the function? Thanks.

Just specify it as T. Look at the docs for the indexer etc for samples.
 
Back
Top