数组1
byte[] byte1 = {1,2,3,4,5,6};
数组2
byte[] byte2;
如何将byte2指向数组1的一个子数组,如{2,3,4,5, 6}或者{3,4,5,6};
就像C++中的指针赋值:
byte2 = &byte1[3];
byte[] byte1 = {1,2,3,4,5,6};
数组2
byte[] byte2;
如何将byte2指向数组1的一个子数组,如{2,3,4,5, 6}或者{3,4,5,6};
就像C++中的指针赋值:
byte2 = &byte1[3];
解决方案 »
- 请教wininet.dll中的InternetSetOption函数的小问题
- socket 判断接受对象的问题
- 关于面向对象的问题.小调查一下.
- 怎么读取一批网页里的表格的内容,然后存到数据库呀
- 请问,在Visio Studio 2008 Team Suite中怎么进行自动测试?自己定义测试规则
- Attempted to read or write protected memory.
- chm帮助文档编译器那里有中文版下载啊!!唧唧啊
- HyperLink 控件是否可以和数据绑定?
- MakeInParam,请问这是什么意思?
- 直接用数据连接打开excel文件
- winform 控件
- C#中窗体标题如何分多行显示??
byte[] byte2 = byte1.Skip(3).ToArray();
具体用法看MSDN
{
fixed (byte* a = new byte[] { 1, 2, 3, 4, 5 })
{
byte* b = a+2;//b从3 开始
}
}
// 前面是个整数数组,表示 List<byte>值的索引,根据索引来指定List<byte>的子数组
List<byte> list = new List<byte> { 1, 2, 3, 4, 5, 6 };
List<int> list1 = new List<int> { 1, 2, 3, 4, 5 };
List<int> list2 = new List<int> { 2, 3, 4, 5 };
{
private T[] _refarray;
private int startpos;
publc SubArray(T[] source, int startpos)
{
_refarray = source; _startpos = startpos;
} public this[int index]
{
get { return _refarray[startpos + index]; }
set { _refarray[startpos + index] = value; }
}
}
SubArray<byte> byte2 = new SubArray<byte>(byte1, 3);
byte2[1] = 0x08;
大哥, 你这种unsafe的代码我看可行, 就跟c++一样, 但如果我分装成一个dll, 提供接口给别人用, 人家会发现这个是unsafe的么? 他们的工程属性也要修改么?