delegates and typed datasets

G

Guest

Hi,

I have this delegate: public delegate DataSet TestDelegate1(string code);
But when I try to pass methods that return a typed dataset instead of a
regular dataset I get an error saying the method does not match the delegate.
Is there a way around that?

Thanks.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

AFAIk the signature should be exact , think what would happen if you have
another delegate with the typed dataset as the return type, at compile time
which one to use?

the solution is fast though , just create another method with the correct
signature and make it return the correct type, like this

DataSet wrapper( string code)
{
return realMethod( code);
}

where realMethod return the typed dataset.


cheers,
 
G

Guest

Ok, thanks!

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

AFAIk the signature should be exact , think what would happen if you have
another delegate with the typed dataset as the return type, at compile time
which one to use?

the solution is fast though , just create another method with the correct
signature and make it return the correct type, like this

DataSet wrapper( string code)
{
return realMethod( code);
}

where realMethod return the typed dataset.


cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top