错误提示如下
un.cs(12,3): error CS1502: 与“System.Console.WriteLine(string,
object)”最匹配的重载方法具有一些无效参数
un.cs(12,49): error CS1503: 参数“2” : 无法从“int*”转换为“object”
un.cs(13,3): error CS1502: 与“System.Console.WriteLine(string,
object)”最匹配的重载方法具有一些无效参数
un.cs(13,49): error CS1503: 参数“2” : 无法从“int*”转换为“object”
un.cs(12,3): error CS1502: 与“System.Console.WriteLine(string,
object)”最匹配的重载方法具有一些无效参数
un.cs(12,49): error CS1503: 参数“2” : 无法从“int*”转换为“object”
un.cs(13,3): error CS1502: 与“System.Console.WriteLine(string,
object)”最匹配的重载方法具有一些无效参数
un.cs(13,49): error CS1503: 参数“2” : 无法从“int*”转换为“object”
x.ToString();
pX.ToString();
pY.ToString();
unsafe class myclass
{
public static int Main()
{
int x=10;
int *pX,pY;
string mn;
pX=&x;
pY=pX;
*pY=20;
mn=pX.ToString();
Console.WriteLine("The result of 'x' is {0}",x);
Console.WriteLine("The result of 'pX' is {0}",mn);
//Console.WriteLine("The result of 'pX' is {0}",pX);
//Console.WriteLine("The result of 'pY' is {0}",pY);
return 0;
}
}
这样不行,错误提示:
Microsoft (R) Visual C# .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.0.3705
版权所有 (C) Microsoft Corporation 2001。保留所有权利。un.cs(12,6): error CS0023: 运算符“.”无法应用于“int*”类型的操作数
mn=System.Convert.ToString((long)pX);
int temp = (int)pX;