I searched huge part of documentations and forums but something is wrong with Visual Studio C# 2010. Maybe I'm wrong but see my code below:
I try to use octal number constants and assign them to "int" variable.
// variable definition
byte L;
// first octal number 021 (17-decimal)
L = 021;
// After that line I see (on debug) L=21
// 021 was treated as decimal not octal !!!
// next test, octal number 056 (46-decimal)
L = 056;
// and I see (on debug) L=56, again wrong !!!
Why????
Loading
VulpesPosted Oct 9, 2013, 10:16 AM
Unlike C/C++, string literals can be used as cases in the switch statement in C#.
So, as long as you make the conversion to an octal string before entering the switch, you could use octal string literals for your cases.
VulpesPosted Oct 9, 2013, 7:47 AM
I suppose you could 'farm out' your octal work to a dll written in one of these languages and then add a reference to that dll to your C# project but it's a tedious workaround.
Instead of the switch statement, you could use an if/else if/else ladder.
belamyPosted Oct 9, 2013, 6:51 AM
VulpesPosted Oct 8, 2013, 1:39 PM
FWIW, you can convert from and to octal strings with:
byte L = Convert.ToByte("021", 8);
// and
string oct = Convert.ToString(L, 8);
but, of course, that's not much use for arithmetic purposes.