Re: Difference between 'out' and 'ref' parameters.
- From: "Chris Mayers" <chris_mayersBLUE@xxxxxxxxxxxxxx>
- Date: Mon, 18 Apr 2005 14:40:00 +0100
Thanks for your answer, that has helped a lot.
There does seem to be another difference though,
this is legal (Compiler allows it)
private int DoStuff(ref string x)
{
x = x + ":";
return -1;
}
wheras this will not compile:
private int DoStuff(out string x)
{
x = x + ":";
return -1;
}
(says " 'Use of unassigned local vairable 'x' ")
This, however is fine:
private into DoStuff(out string x)
{
x = "1";
return -1;
}
So you can't pass a value INTO a method using a 'out' parameter like you can
with a 'ref' parameter. (?) I guess that's why its called 'out' :-)
Chris
.
- Follow-Ups:
- Jorge: Difference between 'out' and 'ref' parameters.
- From: Chris Mayers
- Re: Difference between 'out' and 'ref' parameters.
- From: Sean Hederman
- Re: Difference between 'out' and 'ref' parameters.
- From: Jorge L Matos
- Jorge: Difference between 'out' and 'ref' parameters.
- References:
- Difference between 'out' and 'ref' parameters.
- From: Chris Mayers
- RE: Difference between 'out' and 'ref' parameters.
- From: Jorge L Matos
- Difference between 'out' and 'ref' parameters.
- Prev by Date: RE: Difference between 'out' and 'ref' parameters.
- Next by Date: Re: Datagrid cell edition ????
- Previous by thread: RE: Difference between 'out' and 'ref' parameters.
- Next by thread: Re: Difference between 'out' and 'ref' parameters.
- Index(es):
Relevant Pages
|