implementinterface.cs

来自「vc的原码例子12 vc的原码例子12」· CS 代码 · 共 57 行

CS
57
字号
using System;
using System.Collections;

interface Book
{
	void ShowBook();
	string GetTitle();
	int GetPages();
	void SetPages(int pages);
}

class NewBook: Book
{
	public string title;
	public int pages;
	public string author;

	public NewBook(string title, string author, int pages)
	{
		this.title = title;
        this.pages = pages;
		this.author = author;
	}

	public string GetTitle()
	{
		return(title);
	}

	public int GetPages()
	{
		return(pages);
	}

	public void SetPages(int pages)
	{
		this.pages = pages;
	}

	public void ShowBook()
	{
		Console.WriteLine("Title: {0}", title);
		Console.WriteLine("Author: {0}", author);
		Console.WriteLine("Pages: {0}", pages);
	}
}

public class ImplementInterface  
{
	public static void Main()  
	{
			NewBook MyNovel = new NewBook("American Dream", "Smith", 600);
		MyNovel.ShowBook();
	}
}

⌨️ 快捷键说明

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