pointerdemo.cs

来自「Csharp实例编程百例.rar」· CS 代码 · 共 28 行

CS
28
字号
using System;

public struct Gas
{
	internal double p;
	internal double t;

	public Gas(double p, double t)
	{
		this.p = p;
		this.t = t;
	}
}

public unsafe class PointerDemo
{
	public static void Main()
	{
		Gas g = new Gas(100.0, 300.0);
		WriteContents(&g);
	}

	public static void WriteContents(Gas* gas)
	{
		Console.WriteLine("p is {0}",gas->p);
		Console.WriteLine("t is {0}",gas->t);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?