using System;
using System.Collections.Generic;
using
System.Linq;
using System.Text;
namespace
ConsoleApplication1
{
class
Program
{
static void Main(string[] args)
{
Audi
audi = new
Audi("linQ",60);
audi[1] =
"A6";
audi[2] =
"A8";
Console.WriteLine(audi[1]);
audi.Run();
audi.ShowResult();
Console.ReadLine();
}
}
public class
Action
{
public static void ToRun(Vehicle
vehicle)
{
Console.WriteLine("{0} is running.",
vehicle.ToString());
}
}
public class
Vehicle
{
private string name;
private int
speed;
private string[] array =
new string[10];
public
Vehicle()
{
}
//限定被相似的名称隐藏的成员
public
Vehicle(string name, int speed)
{
this.name =
name;
this.speed = speed;
}
public virtual void
ShowResult()
{
Console.WriteLine("The top speed of {0} is {1}.", name,
speed);
}
public void
Run()
{
//传递当前实例参数
Action.ToRun(this);
}
//声明索引器,必须为this,这样就可以像数组一样来索引对象
public string this[int param]
{
get {
return array[param];
}
set {
array[param] = value; }
}
}
public class Car :
Vehicle
{
//派生类和基类通信,以base实现,基类首先被调用
public
Car()
:
base("Car", 200)
{
}
//指定创建派生类实例时应调用的基类构造函数
public
Car(string name, int
speed)
:
this()
{
}
public override void
ShowResult()
{
//调用基类上已被其他方法重写的方法
base.ShowResult();
Console.WriteLine("It‘s a car‘s
result.");
}
}
public class Audi : Car
{
public
Audi()
:
base("Audi", 300)
{
}
public Audi(string name, int
speed)
:
this()
{
}
public override void
ShowResult()
{
//由三层继承可以看出,base只能继承其直接基类成员
base.ShowResult();
base.Run();
Console.WriteLine("It‘s audi‘s
result.");
}
}
}
C# this和base
时间: 2024-10-10 07:48:01
C# this和base的相关文章
nova - nova base image id的生成算法
nova spawn instance的时候,会先create_image,下面是获取的base image的函数 def get_cache_fname(images, key): """Return a filename based on the SHA1 hash of a given image ID. Image files stored in the _base directory that match this pattern are c
使用国内镜像通过pip安装python的一些包 Cannot fetch index base URL http://pypi.python.org/simple/
原文地址:http://www.xuebuyuan.com/1157602.html 学习flask,安装virtualenv环境,这些带都ok,但是一安装包总是出错无法安装, 比如这样超时的问题: (env)[email protected]:~/flask_study/venv-test/test$ easy_install Flask-SQLAlchemy Searching for Flask-SQLAlchemy Reading http://pypi.python.org/simpl
thinkphp中SQLSTATE[42S02]: Base table or view not found: 1146 Table错误解决方法
随手记录下今天在thinkphp3.2.3中遇到的错误SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.file_info' doesn't exist,之前用pdo连接数据库一直没有问题,今天突然发现报了上述错误,查看了别人的解决方法,都没有解决,后来看了下之前的表名都是小写的,我现在的表名是"file_Info",改为"file_info"后就不报异常了
(转)C# :base的用法(冒号后面的base)
c# 中关于: base()用法,在此记录一下,方便查阅 1.this是标识当前资源对象的,而base是基于父级的. 2.base发挥了期灵魂级的作用--多态 3.base子类可以访问父类成员 4.base调用父类方法必须重写父类方法 5.base子类构造函数直接访问:base父类构造方法 6.base同样不能用于静态方法 public abstract class HttpBasedTransport : ClientTransportBase { protected HttpBasedTra
python 实现 math.log(x,base)
python 用闭包实现math.log(x,base) #!/usr/bin/python3 # -*- coding: utf-8 -*- import sys,math import random import pprint def log(n,d): i = 0 status = 0 while True: if d**i==n: status=1 break elif d**i<n<d**(i+1): break i+=1 def test(level=100): if status
(paper reading)Entity Linking with a Knowledge Base: Issues, Techniques, and Solutions
给定一个包含一系列实体E的知识库,以及提到了M个已确定实体的文本集合,实体链接的目的是将文本中提到的每个实体m∈M链接到知识库中对应的实体e∈E上.如果文本中提到的实体在知识库中没有对应,则被称为unlinkable mentions,对这样的一类实体,一个实体链接系统会给它加上一个特殊的标签NIL. 一个典型的实体链接系统应该包含三个模块: Candidate entity generation 对M当中的每一个m,实体链接系统需要在知识库中找出候选的实体集合Em,主要的实现方法有: dict
What is base..ctor(); in C#?
I am disassembling some C# applications and I am trying to reconstruct the source code. I am disassembling the application along with the required DLLs.I keep coming across this line base..ctor(); which gives me an error. The line occurs in some void
504. 十进制转换为7进制(考虑负数的情况)Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will be in range of [-1e7, 1e7]. public class Solution { public string ConvertToBase7(int
Python Base Four
35. In python, file operation syntax is similar to c. open(file,'r',……) //the first parameters is necessary, other is optional ,the second parameters is 'r' by default if you want to open a file, you can use: f = open('//Users//wyg_mac//Desktop//Acco
google base库中的WaitableEvent
这个类说白了就是对windows event的封装,没有什么特别的,常规做法,等侍另一线程无非就是等侍事件置信waitsingleobject,通知事件无非就是setevent,一看就明白,不就详解,写在这里只是为了这个系更的完整性 下边的示例代码注意下: // WaitableEvent *e = new WaitableEvent; // SendToOtherThread(e); // e->Wait(); // delete e; SendToOtherThread(e); 这个应当就