K
Kimmo Laine
Hi,
stupid question: Why can´t i do this:
public enum eMy: byte {
Item1 = 1,
Item2 = 127,
Item3 = 128,
Item4 = 255,
}
void MyFunc() {
eMy b = eMy.Item3;
Foo( b );
}
void Foo( object o ) {
int i = ( int )o;
}
I get the "Specified cast is not valid."-exception. I must do double cast:
int i = ( int )( eMy )o;
And another thing: if i look the variable b in Debugger - it shows that the
value is "-128" not 128? Its a little confusing - when i code something like
this...
static void Foo( object o ) {
int i = (int)(eMy)o;
eMy d = eMy.Item3;
if( i == ( int )d ) {
// we go here
}
}
....and debug it: it clearly states that "c" is "-128" and "i" is "128" - i
== d -> 128 == -128!
Kimmo Laine
stupid question: Why can´t i do this:
public enum eMy: byte {
Item1 = 1,
Item2 = 127,
Item3 = 128,
Item4 = 255,
}
void MyFunc() {
eMy b = eMy.Item3;
Foo( b );
}
void Foo( object o ) {
int i = ( int )o;
}
I get the "Specified cast is not valid."-exception. I must do double cast:
int i = ( int )( eMy )o;
And another thing: if i look the variable b in Debugger - it shows that the
value is "-128" not 128? Its a little confusing - when i code something like
this...
static void Foo( object o ) {
int i = (int)(eMy)o;
eMy d = eMy.Item3;
if( i == ( int )d ) {
// we go here
}
}
....and debug it: it clearly states that "c" is "-128" and "i" is "128" - i
== d -> 128 == -128!
Kimmo Laine