And just to add to Jon’s reply. Think about what would happen if that
was allowed. In the example below the caller is sending a type
“DerivedClass” but the function being called is only required to
return a type of “BaseClass” so you can see how this would create a
problem.
class BaseClass
{
}
class DerivedClass : BaseClass
{
}
class Program
{
static void Main(string[] args)
{
DerivedClass n = new DerivedClass();
DoIt(ref n);
}
static void DoIt(ref BaseClass niceClass)
{
niceClass = new BaseClass();
}
}
On Jun 3, 11:08*am, "Jon Skeet [C# MVP]" <sk...@pobox.comwrote:
On Jun 3, 3:47 pm, "sheper...@googlemail.com"
<sheper...@googlemail.comwrote:
Hi,
I have a stored procedure in my database and it has an argument of
type output (int).
When I create a dataset using VS2005, it creates a table adapter for
me and the Fill method has and argument of type
ref int?.
When I try to call the Fill method it prompts an error and says cannot
convert ref int to ref int?.
Does anyone know how should I call this Fill method?
Yes - supply it with a ref int? instead:
int? foo = null;
Fill (..., ref foo);
You can't do that if foo isn't nullable - for "ref" parameters, the
argument type (i.e. what you're calling the method with) has to match
the parameter type (i.e. what the method has declared) exactly.
Jon