actionscript 3 - how to convert action script 3 to c#? -
all.
i trying parse binary(amf3) data using c#.
and have found useful class , functions https://code.google.com/p/cvlib/source/browse/trunk/as3/com/coursevector/amf/amf3.as
and has got static function below.
class uuidutils { private static var upper_digits:array = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' ]; public static function frombytearray(ba:bytearray):string { if (ba != null && ba.length == 16) { var result:string = ""; (var i:int = 0; < 16; i++) { if (i == 4 || == 6 || == 8 || == 10) result += "-"; result += upper_digits[(ba[i] & 0xf0) >>> 4]; result += upper_digits[(ba[i] & 0x0f)]; } return result; } return null; } }
it looks java, it's not.
and think it's action script 3.
anyway, came across here convert c#.
so code below.
static string[] upper_digits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; static string fromamf3bytearray(byte[] ba) { if (ba != null && ba.length == 16) { string result = ""; (int = 0; < 16; i++) { if (i == 4 || == 6 || == 8 || == 10) result += "-"; result += upper_digits[(ba[i] & 0xf0) >>> 4]; result += upper_digits[(ba[i] & 0x0f)]; } return result; } return null; }
but getting syntax error @ result += upper_digits[(ba[i] & 0xf0) >>> 4];.
anyone can give me advise >>> ?
>>>
bitwise unsigned right shift operator in actionscript. it's equivalent right-shift operator in c# when applied unsigned type (byte, uint, ulong). please find below correct translation:
private static string fromamf3bytearray(byte[] ba) { if (ba != null && ba.length == 16) { string result = ""; (int = 0; < 16; i++) { if (i == 4 || == 6 || == 8 || == 10) result += "-"; result += upper_digits[(ba[i] & 0xf0) >> 4]; result += upper_digits[(ba[i] & 0x0f)]; } return result; } return null; }
Comments
Post a Comment