473,472 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Out parm syntax error

I have a method which returns a value via an out parm. Here's the prototype of the function:
public DbActionResult Insert(out int securityGroupID, string title, string description)

Now, when I try to pull the value out of that list, no matter the syntax, I can't get it to work... keep getting an error of "can't convert out int to int" or vice versa.

Data.SecurityGroup sg = new Data.SecurityGroup();
result = sg.Insert(out securityGroup.GroupID,
securityGroup.Title,
securityGroup.Description);
_securityGroup = securityGroup;

Any ideas what's throwing my error? It looks like everything I'm doing is correct. I also tried using a temp variable (int goupID = 0) in place of the securityGroup.GroupID property and then assigning that temp to the object property, but I got the same error.

--
-AC
Nov 15 '05 #1
3 1156
Andrew,

The property will never work, as you can not assign a property to a
"ref" parameter or to an "out" parameter. The idea is that on return, the
assignment can not be made (an assignment for a property is like another
method call, it is not like the assignment of a field).

This is going to sound like a foolish question, but when you assign the
value to the temp variable, do you use "out" on that variable as well when
passing to the method?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andrew Connell" <sp**@aNO-SPAM-MEconnell.com> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
I have a method which returns a value via an out parm. Here's the prototype
of the function:
public DbActionResult Insert(out int securityGroupID, string title, string
description)

Now, when I try to pull the value out of that list, no matter the syntax, I
can't get it to work... keep getting an error of "can't convert out int to
int" or vice versa.

Data.SecurityGroup sg = new Data.SecurityGroup();
result = sg.Insert(out securityGroup.GroupID,
securityGroup.Title,
securityGroup.Description);
_securityGroup = securityGroup;

Any ideas what's throwing my error? It looks like everything I'm doing is
correct. I also tried using a temp variable (int goupID = 0) in place of
the securityGroup.GroupID property and then assigning that temp to the
object property, but I got the same error.

--
-AC
Nov 15 '05 #2
Makes sense RE the property (looks like I have a lot of things to go back
and fix).

In response to your question: Do you mean doing something like this?

Data.SecurityGroup sg = new Data.SecurityGroup();
int groupID = 0;
result = sg.Insert(out groupID,
securityGroup.Title,
securityGroup.Description);
securityGroup.GroupID = groupID;
_securityGroup = securityGroup;

I'm fairly certain I did try that.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OI**************@TK2MSFTNGP11.phx.gbl...
Andrew,

The property will never work, as you can not assign a property to a
"ref" parameter or to an "out" parameter. The idea is that on return, the
assignment can not be made (an assignment for a property is like another
method call, it is not like the assignment of a field).

This is going to sound like a foolish question, but when you assign the value to the temp variable, do you use "out" on that variable as well when
passing to the method?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andrew Connell" <sp**@aNO-SPAM-MEconnell.com> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
I have a method which returns a value via an out parm. Here's the prototype of the function:
public DbActionResult Insert(out int securityGroupID, string title, string
description)

Now, when I try to pull the value out of that list, no matter the syntax, I can't get it to work... keep getting an error of "can't convert out int to
int" or vice versa.

Data.SecurityGroup sg = new Data.SecurityGroup();
result = sg.Insert(out securityGroup.GroupID,
securityGroup.Title,
securityGroup.Description);
_securityGroup = securityGroup;

Any ideas what's throwing my error? It looks like everything I'm doing is
correct. I also tried using a temp variable (int goupID = 0) in place of
the securityGroup.GroupID property and then assigning that temp to the
object property, but I got the same error.

--
-AC

Nov 15 '05 #3
Andrew,

Can you give the compiler error that you are getting for this? The
syntax that you are using looks like it should work (with the local
variable).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andrew Connell" <sp**@aNO-SPAM-MEconnell.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Makes sense RE the property (looks like I have a lot of things to go back
and fix).

In response to your question: Do you mean doing something like this?

Data.SecurityGroup sg = new Data.SecurityGroup();
int groupID = 0;
result = sg.Insert(out groupID,
securityGroup.Title,
securityGroup.Description);
securityGroup.GroupID = groupID;
_securityGroup = securityGroup;

I'm fairly certain I did try that.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:OI**************@TK2MSFTNGP11.phx.gbl...
Andrew,

The property will never work, as you can not assign a property to a
"ref" parameter or to an "out" parameter. The idea is that on return, the assignment can not be made (an assignment for a property is like another
method call, it is not like the assignment of a field).

This is going to sound like a foolish question, but when you assign the
value to the temp variable, do you use "out" on that variable as well when passing to the method?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Andrew Connell" <sp**@aNO-SPAM-MEconnell.com> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
I have a method which returns a value via an out parm. Here's the

prototype
of the function:
public DbActionResult Insert(out int securityGroupID, string title, string description)

Now, when I try to pull the value out of that list, no matter the syntax, I
can't get it to work... keep getting an error of "can't convert out int

to int" or vice versa.

Data.SecurityGroup sg = new Data.SecurityGroup();
result = sg.Insert(out securityGroup.GroupID,
securityGroup.Title,
securityGroup.Description);
_securityGroup = securityGroup;

Any ideas what's throwing my error? It looks like everything I'm doing is correct. I also tried using a temp variable (int goupID = 0) in place of the securityGroup.GroupID property and then assigning that temp to the
object property, but I got the same error.

--
-AC


Nov 15 '05 #4

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

Similar topics

4
by: Don | last post by:
Using PHP, I'm creating an <input> tag. How do you delimit the text string for the value parm of an <input> tag, when the string contains the delimit char? Example: <input...value="This text...
1
by: droope | last post by:
I am trying to create a proc with a parm @whereclause that will have a value passed in of one to many policy ids. The parm coming into the proc looks like this, ('000000000108', '000000000106',...
22
by: Gene Wirchenko | last post by:
Is the following guaranteed safe? void InitInt(int & SomeInt) { SomeInt=3; return; } int main() {
2
by: Angel | last post by:
I'm exporting a C-style function call with this syntax: int getDate(char *date); I'm trying to export to my c# app like this: public static extern int getDate(System.IntPtr ptr); public...
6
by: Angel | last post by:
I'm exporting (with DllImport) a C-style function with this syntax: int z9indqry (4_PARM *parm); 4_PARM is a structure declared in a proprietary header file that cannot be included in my...
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a template column of a gridview. i have a hyperlink in the Item Template and i'm trying to do a custom binding expression to it. So far i have the following: Eval("FILE_ID",...
4
by: Chris Forone | last post by:
hello group, i have a class as template parm for another class. in ctor of the parameterized class i use a local instance of class from parm. ctor of param-class compiles fine, but i cant call...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.