class class1void sf()
{string[] x =new string[]{"sfds","fsdf"}}
请问x存在堆栈中还是堆中,还是堆栈中和堆中都有?

解决方案 »

  1.   

    Console.WriteLine("string [] is valuetype is {0}",typeof(string[]).IsValueType);
    Console.WriteLine("string is valuetype is {0}", typeof(string).IsValueType);
    Console.ReadLine();
    加上这三句看看结果
      

  2.   

    哦,我明白了,你们没明白我的意思
    我换个数组class class1void sf()
    {int[] x =new int[]{1,2,3}}
    请问x存在堆栈中还是堆中,还是堆栈中和堆中都有?
      

  3.   

    x是引用,在堆中,存放x[1]x[2]的地址,x[1],x[2]的值存放在栈中
      

  4.   

    x在栈中,new int[]{1,2,3}在堆中。
    x是一个引用,说白了就是一个表示地址的值。