当前位置:网站首页>C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep268
C graphical tutorial (Fourth Edition)_ Chapter 15 interface: interfacesamplep268
2022-07-03 12:52:00 【superfreak】
using System;
namespace Chapter15InterfaceSampleP268
{
interface IInfo
{
string GetName();
string GetAge();
}
class CA :IInfo
{
public string Name;
public int Age;
public string GetName() { return Name; }
public string GetAge() { return Age.ToString(); }
}
class CB : IInfo
{
public string First;
public string Last;
public double PersonAge;
public string GetName() { return First+""+Last; }
public string GetAge() { return PersonAge.ToString(); }
}
class Program
{
static void PrintInfo(IInfo item)
{
Console.WriteLine("Name:{0},Age:{1}",item.GetName(),item.GetAge());
}
static void Main(string[] args)
{
CA a = new CA() { Name = "JohnDoe", Age = 35 };
CB b = new CB() { First = "Jane",Last= "Doe",PersonAge = 33 };
PrintInfo(a);
PrintInfo(b);
Console.WriteLine("Hello World!");
}
}
}
边栏推荐
- Xctf mobile--app2 problem solving
- 公纵号发送提示信息(用户微服务--消息微服务)
- Swift return type is a function of function
- It feels great to know you learned something, isn‘t it?
- Ali & ant self developed IDE
- How to convert a decimal number to binary in swift
- 剑指Offer05. 替换空格
- Node.js: express + MySQL的使用
- Harmonic current detection based on synchronous coordinate transformation
- [review questions of database principles]
猜你喜欢
Xctf mobile--app1 problem solving
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?
Sword finger offer14 the easiest way to cut rope
ncnn神經網絡計算框架在香柳丁派OrangePi 3 LTS開發板中的使用介紹
剑指Offer04. 二维数组中的查找【中等】
【数据库原理及应用教程(第4版|微课版)陈志泊】【SQLServer2012综合练习】
Xctf mobile--rememberother problem solving
2021 autumn Information Security Experiment 1 (password and hiding technology)
TOGAF认证自学宝典V2.0
Togaf certification self-study classic v2.0
随机推荐
studio All flavors must now belong to a named flavor dimension. Learn more
node的ORM使用-Sequelize
【习题五】【数据库原理】
Project video based on Linu development
十条职场规则
RedHat5 安装Socket5代理服务器
Tianyi ty1208-z brush machine detailed tutorial (free to remove)
Four problems and isolation level of MySQL concurrency
【习题六】【数据库原理】
并网-低电压穿越与孤岛并存分析
Sqoop1.4.4原生增量导入特性探秘
剑指Offer03. 数组中重复的数字【简单】
Day 1 of kotlin learning: simple built-in types of kotlin
Social community forum app ultra-high appearance UI interface
Simple use and precautions of kotlin's array array and set list
Xctf mobile--rememberother problem solving
启用MemCached的SASL认证
Grid connection - Analysis of low voltage ride through and island coexistence
阿里 & 蚂蚁自研 IDE
With pictures and texts, summarize the basic review of C language in detail, so that all kinds of knowledge points are clear at a glance?