如: byte [] a=new byte[6];
如何获得该数组指针?
我使用了 &a[0],结果返回错误是: “只能获取固定语句初始值设定项内的未固定表达式的地址”

解决方案 »

  1.   

    unsafe void CopyPtr()
    {
    int *ptr = null;
    int num = 10;
    ptr = #
    MessageBox.Show((*ptr).ToString());
    }并且将项目属性中'生成'项中的'允许不安全代码块'置为true
      

  2.   

    int[] source = new int[] {41, 42, 43, 44};
    fixed(int *ptr = &source[0])
    {
    int x = *ptr;
    MessageBox.Show(x.ToString());
    }
      

  3.   

    fixed在unsafe 应用
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003APR.1033/csref/html/vclrfFixed.htmIntPtr
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003APR.1033/cpref/html/frlrfSystemIntPtrClassctorTopic.htmhttp://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfSystemIntPtrClassTopic.asp