📄 class1.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 + -