⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 C#开发教程 由浅入深 配有实例 是初学者的好帮手
💻 CS
字号:
using System;

namespace ClassAddress
{
    public struct Insect
    {
        public int id;
        public Insect(int id) { this.id = id; }
    }
    class ClassAddressApp
    {
        unsafe public static Insect[] CloneInsects(Insect[] box)
        {
            Insect[] ret = new Insect[box.Length];
            fixed (Insect* src = box, dest = ret)
            {
                Insect* pSrc = src;
                Insect* pDest = dest;
                for (int index = 0; index < box.Length; index++)
                {
                    *pDest = *pSrc;
                    Console.WriteLine(
                        "{0} is at {1}", pDest->id, (int)pDest);
                    pSrc++;
                    pDest++;
                }
            }
            return ret;
        }

        [STAThread]
        static void Main(string[] args)
        {
            Insect[] box = new Insect[2];
            box[0] =  new Insect(123);
            box[1] = new Insect(456);
 
            Insect[] bag = CloneInsects(box);
            foreach (Insect i in bag)
            {
                Console.WriteLine(i.id);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -