|
|
#1 |
|
Site Team
Join Date: Dec 2002
Posts: 15,209
|
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?
__________________
www.ComputerForums.org |
|
|
|
|
|
#2 |
|
In Runtime
|
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:
Code:
void Main() {
String myName;
SetMyName(out myName);
Console.WriteLine(myName);
} // end Main
void SetMyName(out String myVal) {
myVal = "Daeva";
} // end SetMyName
*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 http://www.twitter.com/xDaevax |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|