473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Argument of type ref int?

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?
Thanks in advance.
Jun 27 '08 #1
4 6135
Supply it with a "ref int?" i.e.

int? arg = 4;
Fill(ref arg);

Marc
Jun 27 '08 #2

int val = 0;
Fill(ref val);
<sh*******@googlemail.comwrote in message
news:53**********************************@l28g2000 prd.googlegroups.com...
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?
Thanks in advance.
Jun 27 '08 #3
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
Jun 27 '08 #4
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
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony Johansson | last post by:
Hello!! Can somebody explain what does argument contravariance mean. I know what covariance mean because this is involved in some way when we have argument contravariance . Use some easy code...
1
by: Mark Dicken | last post by:
Hi All I have found the following Microsoft Technet 'Q' Article :- Q210368 -ACC2000: How to Pass an Array as an Argument to a Procedure (I've also copied and pasted the whole contents into...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
4
by: MattBell | last post by:
I've tried to search for an answer to this without much success, and I think it's probably a common thing to do: I have a web service I want to accept an XmlDocument as an argument which conforms...
5
by: shaanxxx | last post by:
i have statements printf("%f",(double)1); /* works fine although i have sent %f for double */ printf("%c",(int)64); /* works fine although i have sent %c for int */ Need your comment on...
20
by: Chris | last post by:
I'm not sure if this has been done before, but I couldn't easily find any prior work on Google, so here I present a simple decorator for documenting and verifying the type of function arguments....
7
by: desktop | last post by:
This page: http://www.eptacom.net/pubblicazioni/pub_eng/mdisp.html start with the line: "Virtual functions allow polymorphism on a single argument". What does that exactly mean? I guess it...
1
by: subramanian100in | last post by:
consider template<typename TTest { // ... }; We can have a pointer type as argument to a template class. For example, we can have, int x = 100; Test<int*obj(&x); // assuming a suitable ctor...
7
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.