G
Guest
Mr. Gunnerson, et. al.
Why does the C# compiler keep on complaining about an "out" parameter that is not assigned when it is really is? Here is the snippet.
using System
namespace BugNam
class Bu
public static Bug Instance = new Bug()
public Bug(){} // cto
static int Main(String[] args) // not voi
int iResultM = 0
Instance.MyIncrementer(out iResultM)
return iResultM
} // end Mai
public void MyIncrementer(out int iArgNum
// iArgNum = 0; // uncomment this and the error goes awa
iArgNum = iArgNum + 1; // causes an error!!!
}
If I uncomment the iArgNum = 0 line, the error goes away
Is this a compiler bug or my bug? After reading the online help, I don't see what I am doing wrong. Notice the original argument was declared as a local variable and was initialized as well (to 0). Then it was passed as an out parameter -- in other words I'm initializing it because I know the function MyIncrementer will be trying to read it before it sets it (and to boot, I didn't even have to use out since out can be used for a variable without initializing it)
What's up
Thanks
Harr
Why does the C# compiler keep on complaining about an "out" parameter that is not assigned when it is really is? Here is the snippet.
using System
namespace BugNam
class Bu
public static Bug Instance = new Bug()
public Bug(){} // cto
static int Main(String[] args) // not voi
int iResultM = 0
Instance.MyIncrementer(out iResultM)
return iResultM
} // end Mai
public void MyIncrementer(out int iArgNum
// iArgNum = 0; // uncomment this and the error goes awa
iArgNum = iArgNum + 1; // causes an error!!!
}
If I uncomment the iArgNum = 0 line, the error goes away
Is this a compiler bug or my bug? After reading the online help, I don't see what I am doing wrong. Notice the original argument was declared as a local variable and was initialized as well (to 0). Then it was passed as an out parameter -- in other words I'm initializing it because I know the function MyIncrementer will be trying to read it before it sets it (and to boot, I didn't even have to use out since out can be used for a variable without initializing it)
What's up
Thanks
Harr