0

recently I have discovered C#, which is really what I want. Before C# I was coding with AS3. I've recoded all my old program using C# but I am blocked with this :

public function Envoie_Serveur(param1:String) : void
{
    var _loc_2:* = String(this.CMDTEC % 9000 + 1000).split("");
    this.Serveur.send(this.MDT[_loc_2[0]] + this.MDT[_loc_2[1]] + this.MDT[_loc_2[2]] + this.MDT[_loc_2[3]] + param1);
    var _loc_3:* = this;
    var _loc_4:* = this.CMDTEC + 1;
    _loc_3.CMDTEC = _loc_4;
    return;
}

CMDTEC and MDT are 2 byteArray (byte[] in C# I guess)

That is what I have tried but which is not working ;c

byte[] _loc_1 = Encode((Int64.Parse(this.CMDTEC[0].ToString("X", System.Globalization.NumberStyles.HexNumber)) % 9000 + 1000) + "");
var fingerprint = new byte[4];

fingerprint[0] = byte.Parse(this.MDT[_loc_1[0]].ToString("X"), System.Globalization.NumberStyles.HexNumber);
fingerprint[1] = byte.Parse(this.MDT[_loc_1[1]].ToString("X"), System.Globalization.NumberStyles.HexNumber);
fingerprint[2] = byte.Parse(this.MDT[_loc_1[2]].ToString("X"), System.Globalization.NumberStyles.HexNumber);
fingerprint[3] = byte.Parse(this.MDT[_loc_1[3]].ToString("X"), System.Globalization.NumberStyles.HexNumber);
this.CMDTEC++;

And for exemple, that is what CMDTEC and MDT contains :

this.MDT = "1400175151406"; (just for exemple, I get this by socket)
this.CMDTEC = "8306"; (idem as ^)

How can I convert properly that to C# please ? Thanks in advance for answers.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Knoweldges
  • 72
  • 8
  • For starters, what line are you getting an error and what exception is the compiler giving you? – bubbinator May 23 '14 at 23:09
  • From what that last chunk of code looks like, you are taking a byte array, putting it into a long (64-bit integer) and then breaking it back into a byte array. Is that what the code is supposed to do? – bubbinator May 23 '14 at 23:11
  • I really don't know how to translate that, so I've tested what I guess the most logic, but the number returned (byte *) was not good. – Knoweldges May 23 '14 at 23:14
  • What about the error messages the compiler is giving you and where? – bubbinator May 23 '14 at 23:20
  • Compilator do not throw an error. But the bytes returned are not what I need :x – Knoweldges May 23 '14 at 23:21
  • Since you are not getting any exceptions, I am thinking that you are using the wrong data. I did notice a mismatch between variable names between the provided code blocks, in the first, you have used `_loc_2` and in the second, you used `_loc_1`. Could that be the issue? – bubbinator May 23 '14 at 23:28
  • 1
    Variable name is not important, I think I am building like a bullshit the bytearray :x – Knoweldges May 23 '14 at 23:30

0 Answers0