C#中继承

父类computer代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace leiku
{
   public class computer
    {
       public computer() { }//类中本身自带的无参构造函数
       public computer(string brand,string model,double price,string color)//也可以定义有参的构造函数
       {
           this.Brand = brand;
           this.Model = model;
           this.Price = price;
           this.Color = color;
       }
      
       public string Brand { get; set; }
       public string Model { get; set; }
       public double Price { get; set; }
       public string Color { get; set; }
             public string ShowInfo()
       {
           return string.Format("品牌{0},系列:{1}价格:{2}颜色:{3}", Brand, Model, Price, Color);
       }
    }
}
子类Desktop.cs的代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace leiku
{
   public class Desktop:computer
    {
       public string CaseColor { get; set; }
    }
}

控制台代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using leiku;

namespace 继承
{
    class Program
    {
        static void Main(string[] args)
        {
            computer com = new computer();//实例化computer类
            //理解:声明父类的变量,无非就是想使用父类中的所有属性,方法,字段等,那么子类的实例中包含所有父类中的属性,方法和字段(不严谨),所以可以将一个子类的实例赋给父类的变量。
            computer com1 = new Desktop();//父类和子类一起定义一个对象,父类必须在前,子类必须在后
          //用一个父类变量指向一个子类实例是可以的,用一个子类变量指向一个父类实例是不行的
            //computer com1=aaa;---这只是定义一个变量
        }
    }
}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
很多,不写全了。。下载下来好好看 ----------Database-------------- 1.DataTable帮助(DataTableHelper.cs) 2.Access数据库文件操作辅助(JetAccessUtil.cs) 5.查询条件组合辅助(SearchCondition.cs) 6.查询信息实体(SearchInfo.cs) 8.Sql命令操作函数(可用于安装程序的时候数据库脚本执行)(SqlScriptHelper.cs) ----------Device-------------- 声音播放辅助(AudioHelper.cs) 摄像头操作辅助,包括开启、关闭、抓图、设置等功能(Camera.cs) 提供用于操作【剪切板】的方法(ClipboardHelper.cs) 获取电脑信息(Computer.cs) 提供用户硬件唯一信息的辅助(FingerprintHelper.cs) 读取指定盘符的硬盘序列号(HardwareInfoHelper.cs) 提供访问键盘当前状态的属性(KeyboardHelper.cs) 全局键盘钩子。这可以用来在全球范围内捕捉键盘输入。(KeyboardHook.cs) 模拟鼠标点击(MouseHelper.cs) 全局鼠标钩子。这可以用来在全球范围内捕获鼠标输入。(MouseHook.cs) MP3文件播放操作辅助(MP3Helper.cs) 关联文件(ExtensionAttachUtil.cs) 注册文件关联的辅助(FileAssociationsHelper.cs) 打开、保存文件对话框操作辅助(FileDialogHelper.cs) 常用的文件操作辅助FileUtil(FileUtil.cs) INI文件操作辅助(INIFileUtil.cs) 独立存储操作辅助(IsolatedStorageHelper.cs) 序列号操作辅助(Serializer.cs) 获取一个对象,它提供用于访问经常引用的目录的属性。(SpecialDirectories.cs) 简单的Word操作对象(WordCombineUtil.cs) 这个提供了一些实用的方法来转换XML和对象。(XmlConvertor.cs) XML操作(XmlHelper.cs) ----------Format-------------- 参数验证的通用验证程序。(ArgumentValidation.cs) 这个提供了实用方法的字节数组和图像之间的转换。(ByteImageConvertor.cs) byte字节数组操作辅助(BytesTools.cs) 处理数据型转换,数制转换、编码转换相关的(ConvertHelper.cs) CRC校验辅助(CRCUtils.cs) 枚举操作公共(EnumHelper.cs) 身份证操作辅助(IDCardHelper.cs) 检测字符编码的(IdentifyEncoding.cs) RGB颜色操作辅助(MyColors.cs) 日期操作(MyDateTime.cs) 转换人民币大小金额辅助(RMBUtil.cs) 常用的字符串常量(StringConstants.cs) 简要说明TextHelper。(StringUtil.cs) 获取文字首字拼写,随机发生器,按指定概率随机执行操作(Util.cs) 各种输入格式验证辅助(ValidateUtil.cs) ----------Network-------------- Cookie操作辅助(CookieManger.cs) FTP操作辅助(FTPHelper.cs) HTML操作(HttpHelper.cs) 网页抓取帮助(HttpWebRequestHelper.cs) Net(NetworkUtil.cs) IE代理设置辅助(ProxyHelper.cs) ----------Winform-------------- 跨线程的控件安全访问方式(CallCtrlWithThreadSafety.cs) CheckBoxList(CheckBoxListUtil.cs) 窗口管理(ChildWinManagement.cs) 由马丁·米勒http://msdn.microsoft.com/en-us/library/ms996492.aspx提供一个简单的方法打印工作的一个RichTextBox一个帮手(ExRichTextBoxPrintHelper.cs) 显示,隐藏或关闭动画形式。(FormAnimator.cs) 对窗体进行冻结、解冻操作辅助(FreezeWindowUtil.cs) 窗体全屏操作辅助(FullScreenHelper.cs) GDI操作辅助(GDI.cs) 提供静态方法来读取这两个文件夹和文件的系统图标。(IconReaderHelper.cs) 图片对象比较、缩放、缩略图、水印、压缩、转换、编码等操作辅助(ImageHelper.cs) 输入法帮助,全角 转换为半角(ImeHelper.cs) Winform提示框 的摘要说明。(MessageUtil.cs) 包含互操作方法调用的应用程序使用。(NativeMethods.cs) 托盘图标辅助(NotifyIconHelper.cs) 打印机(POSPrinter.cs) 图片、光标、图标、位图等资源操作辅助(ResourceHelper.cs) RTF字符格式辅助(RTFUtility.cs) 串口开发辅助(SerialPortUtil.cs) 设置文本属性提供一个ToolStripStatusLabel(SafeToolStripLabel.cs) 只运行一个实例及系统自动启动辅助(StartupHelper.cs) Web页面预览效果图片抓取辅助(WebPageCapture.cs) 供Asp.Net直接调用的包装(WebPreview.cs) 计算机重启、关电源、注销、关闭显示器辅助(WindowsExitHelper.cs) 简单写了点,还有很多,希望能对大家有帮助 ================================================================================================ 本资料共包含以下附件: WHC.OrderWater.Commons.rar 公共文档.docx

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值