int* fib= stackalloc int[100];//Alloc memory for int[100] in stack
int* p=fib;
//let pointer p point to the same address as fib pointed to
*p++ = *p++=1; // p++; *p=1; p++; *p=1;
int* p=fib;
//let pointer p point to the same address as fib pointed to
*p++ = *p++=1; // p++; *p=1; p++; *p=1;
if you want get length of a string,you should use the "Length" property of the string class.
can't sizeof
{
static void Main()
{ unsafe
{
string str1="long";
Console.WriteLine("siaeof long is {0}",sizeof(str1));
}
}
}
可以将以上的例子改为:
using System;
class C1
{
static void Main()
{ unsafe
{Console.WriteLine("sizeof long is {0}",sizeof(long));
}
}
}
就可以编译运行通过。
得到的结果:sizeof long is 8.