帮忙C# 程序改错误。
using System;
public class addrsOpr
{
unsafe public static int Main(string[] args)
{
// addrsOpr.cs
// A C# program demonstrating how to use
// the Binary AND operator & to return
// the address of an unsafe value
// PROGRAM DOES NOT COMPILE - erad last comment!!!
// Copyright (c) Chris H. Pappas and William H. Murray, 2001
//
Console.WriteLine("& used on true AND true = {0}", true & true);
Console.WriteLine("& used on true AND false = {0}", true & false);
int iValue = 4;
// the following "fixed" block IS crrect - hower,
// the program will NOT compile - WHY?
fixed(int *pi = &iValue)
{
string hexAddress = int.Format((int)pi, "x");
Console.WriteLine("& returning address of iValue: {0}", hexAddress);
// or the simpler version, not using teh string variable
Console.WriteLine("& returning address of iValue: {0}", int.Format((int)pi, "x"));
}
// to get addrsOpr.cs to compile and execute
// your MUST remember - ANY method using unsafe pointers
// must include the "unsafe" keyword in the method prototype
// when you change Main()'s prototype to:
// unsafe public static int Main(string[] args)
// the program will compile and execute!
return 0;
}
}