Jump to content

Recommended Posts

Posted

Hi AutoIt Programmers, i wanna figure out how to use Binary functions in C# like:

BinaryMid
BinaryLen

IsBinary and other basic ones were too ez, but those two were hard to noob like me.

I appreciate for your helps/hints.

Posted

Hello. You can use power of C# byte[] functions.

 

Like: 

static void Main(string[] args)
        {

            var str = "Hello World";
            var bytes = Encoding.ASCII.GetBytes(str);

            string hexstr = BitConverter.ToString(bytes);
            Console.WriteLine(hexstr.Replace("-","") + " = " + Encoding.ASCII.GetString(bytes));
            Console.WriteLine("BinaryLen: " + (bytes.Length));
            Console.WriteLine("");

           //BinaryMid($dBinary, 1, 5)
            byte[] bytesMid = new byte[5];
            Array.Copy(bytes,0, bytesMid, 0, bytesMid.Length);
            hexstr = BitConverter.ToString(bytesMid);
            Console.WriteLine("BinaryMid(bytes, 1, 5)");
            Console.WriteLine(hexstr.Replace("-", "") +" = " + Encoding.ASCII.GetString(bytesMid));
            Console.WriteLine("BinaryLen: " + (bytesMid.Length));
            Console.WriteLine("");

            //BinaryMid($dBinary, 7, 5)
            bytesMid = new byte[5];
            Array.Copy(bytes, 6, bytesMid, 0, bytesMid.Length);
            hexstr = BitConverter.ToString(bytesMid);
            Console.WriteLine("BinaryMid(bytes, 7, 5)");
            Console.WriteLine(hexstr.Replace("-", "") + " = " + Encoding.ASCII.GetString(bytesMid));
            Console.WriteLine("BinaryLen: " + (bytesMid.Length));



            Console.ReadKey();
        }

 

Saludos

  • Colduction changed the title to [SOLVED] AutoIt Binary funcs into C#

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...