How to use Buffer.GetByte() to get the values of int array in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[] { 1, 2, 3 };

            for (int i = 0; i < Buffer.ByteLength(arr); i++)
                Console.WriteLine(Buffer.GetByte(arr, i));
        }
    }
}

/*
run:
 
1
0
0
0
2
0
0
0
3
0
0
0
 
*/

 



answered Jan 6, 2017 by avibootz
edited Jan 6, 2017 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[] { 13, 222 };

            for (int i = 0; i < Buffer.ByteLength(arr); i++)
                Console.WriteLine(Buffer.GetByte(arr, i));
        }
    }
}

/*
run:

13
0
0
0
222
0
0
0

*/

 



answered Jan 6, 2017 by avibootz
edited Jan 6, 2017 by avibootz
...