G
Guest
In this case, I am trying to perfom a math function on a byte value with
another byte value returned by a function. There appears to be no way to
convince the compiler to do this even with explicit casts. Works fine if the
values being added are constants, but when one is a function it doesn't work
correctly.
Is this a compiler bug or am I missing something?
// VS 2003.net C# code
public class Class1
{
public Class1()
{
}
private byte ByteFunc()
{
return (byte)1;
}
public void MyFunc()
{
byte byOut;
byOut = 1; // OK: No error
byOut = 1*1; // OK: No error
byOut = (byte)1*(byte)2; // OK: No error
byOut = ByteFunc(); // OK: No error
byOut = ByteFunc() * 2; // ERROR: Cannot implicitly convert 'int'
to 'byte'
byOut = (byte)ByteFunc() * (byte)2; // ERROR: Cannot implicitly
convert 'int' to 'byte'
}
}
another byte value returned by a function. There appears to be no way to
convince the compiler to do this even with explicit casts. Works fine if the
values being added are constants, but when one is a function it doesn't work
correctly.
Is this a compiler bug or am I missing something?
// VS 2003.net C# code
public class Class1
{
public Class1()
{
}
private byte ByteFunc()
{
return (byte)1;
}
public void MyFunc()
{
byte byOut;
byOut = 1; // OK: No error
byOut = 1*1; // OK: No error
byOut = (byte)1*(byte)2; // OK: No error
byOut = ByteFunc(); // OK: No error
byOut = ByteFunc() * 2; // ERROR: Cannot implicitly convert 'int'
to 'byte'
byOut = (byte)ByteFunc() * (byte)2; // ERROR: Cannot implicitly
convert 'int' to 'byte'
}
}