Go Back   Computer Forums > Web Design | Website Development > Web Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 10-22-2009, 04:23 PM   #1
Site Team
David Lindon's Avatar
Join Date: Dec 2002
Posts: 15,233
Default c# 'out object'

How do you declare an 'out object'? For example:

GetField(string FieldName, out object value);

So if I wanted to get the field 'IO-Name' and store it in the 'Name' variable how can I do it?

[url=http://www.LNXPS.NET]LNXPS.NET - The XPS Library]
David Lindon is offline   Reply With Quote
Old 11-04-2009, 09:37 PM   #2
In Runtime
Daeva's Avatar
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: c# 'out object'

I personally think that methods that return a value are a simpler alternative. I hadn't even heard of 'out' objects until recently. But I believe the correct implementation goes something like this:

void Main() {

   String myName;

   SetMyName(out myName);

} // end Main

void SetMyName(out String myVal) {
   myVal = "Daeva";
} // end SetMyName
I didn't compile that, but hopefully that helps.

*EDIT: Note that it is important to not initialize the value being assigned with out.
**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
Daeva is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 09:35 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0