⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class1.cs

📁 C#开发教程 由浅入深 配有实例 是初学者的好帮手
💻 CS
字号:
using System;

namespace WindowByRef
{
	class Window
	{
		public Window(int x, int y)
		{
			this.x = x;
			this.y = y;
		}

		protected int x;
		protected int y;

		public void Move(int x, int y)
		{
			this.x = x;
			this.y = y;
		}

		public void ChangePos(ref int x, ref int y)
		{
			this.x += x;;
			this.y += y;

			x = this.x;
			y = this.y;
		}
	}

	class TestWindowByRef
	{
		public static void Main()
		{
			Window wnd = new Window(5, 5);
			int x = 5;
			int y = 5;

			wnd.ChangePos(ref x, ref y);
			Console.WriteLine("{0}, {1}", x, y);

			x = -1;
			y = -1;
			wnd.ChangePos(ref x, ref y);
			Console.WriteLine("{0}, {1}", x, y);
		}
	}
}

⌨️ 快捷键说明

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