How to use Buffer.ByteLength() to count the bytes of int array in C#

1 Answer

0 votes
using System;

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

            int len = Buffer.ByteLength(arr);

            Console.WriteLine(len);
        }
    }
}

/*
run:

28

*/

 



answered Jan 6, 2017 by avibootz
...