小编Rag*_*aav的帖子

将双数组转换为字节数组

如何将double[]数组转换为数组,byte[]反之亦然?

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(sizeof(double));
        Console.WriteLine(double.MaxValue);

        double[] array = new double[] { 10.0, 20.0, 30.0, 40.0 };
        byte[] convertedarray = ?

        Console.Read();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# c#-3.0

12
推荐指数
2
解决办法
2万
查看次数

线程同步

必须在线程之间共享数据.哪种方法最好同步?

锁是更好的方法还是Mutex?

namespace ConsoleApplication8
{
    class Data
    {
        public int X
        {
            set;
            get;
        }

        public int Y
        {
            get;
            set;
        }

        public int result;
    }

    class Program
    {
        static int a;
        private static object aLock = new object();

        static void Main(string[] args)
        {
            ParameterizedThreadStart aStart = new ParameterizedThreadStart(Addition);
            Thread aThread = new Thread(aStart);
            Data aData = new Data();
            aData.X = 10;
            aData.Y = 20;

            Thread aThread2 = new Thread(aStart);
            aThread2.Start();


            aThread.Start(aData);
            aThread.Join();
            aThread2.Join();
            Console.WriteLine("End of the program");
        }

        static …
Run Code Online (Sandbox Code Playgroud)

c# thread-synchronization

3
推荐指数
1
解决办法
439
查看次数

标签 统计

c# ×2

c#-3.0 ×1

thread-synchronization ×1