class1.cs

来自「提供了大量初学CSharp的示例」· CS 代码 · 共 68 行

CS
68
字号
using System;

namespace AssociateUse
{
	interface NameBase
	{
		void GetName(int i);
	}

	interface NameA:NameBase
	{}

	interface NameB:NameBase
	{}

	class Name:NameA, NameB
	{
		private int id;
		public Name()
		{
			
		}

		public Name(int id)
		{
			this.id = id;
		}

		public void GetName(int i)
		{
			if (i==0)
				Console.WriteLine("This is a Name");
			
				
		}

		public int GetId()
		{
			return id;
		}
	}

	class MyName
	{
		//private Name theName;
		//private string name;
		public MyName()
		{
		}

		public void GetName(int i)
		{
			NameA theName = (NameA)new Name();
			//if (theName is NameA)
			theName.GetName(i);
		}
	}

	class Test
	{
		public static void Main()
		{
			MyName myName = new MyName();
			myName.GetName(0);
		}
	}
}

⌨️ 快捷键说明

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