Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

simple one on out parameters in functions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WebBuilder451 - 06 Sep 2007 15:50 GMT
i have this in a class:
   public void fn_X(out Int32 j)
   {
       j = 5;
   }
i call it by using:

reportFunctionsCS rfcs = new reportFunctionsCS();
Int32 j = 0;
rfcs.fn_X(j);
it always gives me this error:
CS1502: The best overloaded method match for 'reportFunctionsCS.fn_X(out
int)' has some invalid arguments
and i have no idea why, but i'm sure it's simple!!!

Signature

(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes

Nicholas Paldino [.NET/C# MVP] - 06 Sep 2007 15:58 GMT
kes,

   When you have an "out" parameter, you have to declare out when making
the call as well, like so:

rfcs.fn_X(out j);

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>i have this in a class:
>    public void fn_X(out Int32 j)
[quoted text clipped - 10 lines]
> int)' has some invalid arguments
> and i have no idea why, but i'm sure it's simple!!!
WebBuilder451 - 06 Sep 2007 16:12 GMT
thanks!
This is one of those "Wayne's World, looking at Alice Cooper moments"
"... I was unaware of that..." And in truth i was NOT!

Thank you, very much appreciated
Signature

(i''ll be asking a lot of these, but I find C# totally way cooler than vb
and there''s no go''n back!!!)
thanks (as always)

kes

> kes,
>
[quoted text clipped - 17 lines]
> > int)' has some invalid arguments
> > and i have no idea why, but i'm sure it's simple!!!
Ignacio Machin ( .NET/ C# MVP ) - 06 Sep 2007 16:03 GMT
Hi,

You also have to use the out keyword when you are calling the method, this
is intended to be use as an indication for the calling code that the value
will be modify inside the method.

>i have this in a class:
>    public void fn_X(out Int32 j)
[quoted text clipped - 10 lines]
> int)' has some invalid arguments
> and i have no idea why, but i'm sure it's simple!!!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.