1. 基础例子

class Dept
{
private string name;
private Emp emp;

  1.  

public string getName()
{
return this.name;
}

  1.  

public void setName(string name)
{
this.name = name;
}

  1.  

public Emp getEmp()
{
return this.emp;
}

  1.  

public void setEmp(Emp emp)
{
this.emp = emp;
}

  1.  

}

  1.  

class Emp
{
private string name;
private string six;
private double tel;
private Auth auth;

  1.  

public string getName()
{
return this.name;
}

  1.  

public void setName(string name)
{
this.name = name;
}

  1.  

public string getsix()
{
return this.six;
}
public void setSix(string six)
{
this.six = six;
}

  1.  
  1.  

public void setTel(double tel)
{
this.tel = tel;
}
public double getTel()
{
return this.tel;
}

  1.  

public void setAuth(Auth auth)
{
this.auth = auth;
}

  1.  

public Auth getAuth()
{
return this.auth;
}

  1.  
  1.  

}

  1.  

class Auth
{
private int x;
private int y;

  1.  

public void setX(int x)
{
this.x = x;
}

  1.  

public int getX()
{
return this.x;
}

  1.  
  1.  

public void setY(int y)
{
this.y = y;
}

  1.  

public int getY()
{
return this.y;
}
}

  1.  

class Program
{

  1.  
  1.  

static void Main(string[] args)
{
//哪个部门里的哪个人有哪些权限

  1.  

Auth auth1 = new Auth();

  1.  

auth1.setX(1);

  1.  

Auth auth2 = new Auth();
auth1.setX(1);
auth2.setY(2);

  1.  

Emp zhangsan = new Emp();
zhangsan.setName("zhangsan");
zhangsan.setSix("nan");
zhangsan.setTel(21321315);
zhangsan.setAuth(auth1);

  1.  

Dept it = new Dept();
it.setName("it");
it.setEmp(zhangsan);
string dept = it.getName();
Console.WriteLine("部门:" + it.getName() + "员工:" + it.getEmp().getName() + "权限" + it.getEmp().getAuth().getX());

  1.  
  1.  

Console.WriteLine("hello word");
Console.ReadLine();
}

  1. 进阶例子
  2.  
  3. namespace sqlgx
  4. {
  5.  
  6. class Dept
  7. {
  8. private int deptid;
  9. private String deptname;
  10. private ArraySegment<User> userarray;
  11.  
  12. public void setdeptid(int deptid)
  13. {
  14. this.deptid = deptid;
  15. }
  16.  
  17. public int getdeptid()
  18. {
  19. return this.deptid;
  20. }
  21.  
  22. public void setdeptname(string deptname)
  23. {
  24. this.deptname = deptname;
  25. }
  26.  
  27. public string getdeptname()
  28. {
  29. return this.deptname;
  30. }
  31.  
  32. }
  33.  
  34. class User
  35. {
  36. private int userid;
  37. private string username;
  38. private int password;
  39. private ArraySegment<Auth> autharray;
  40. private ArraySegment<Manue1> manue1array;
  41.  
  42. public void setuserid(int userid)
  43. {
  44. this.userid = userid;
  45. }
  46.  
  47. public int getuserid()
  48. {
  49. return this.userid;
  50. }
  51.  
  52. public void setusername(string username)
  53. {
  54. this.username = username;
  55. }
  56.  
  57. public string getusername()
  58. {
  59. return this.username;
  60. }
  61.  
  62. public void setpassword(int password)
  63. {
  64. this.password = password;
  65. }
  66.  
  67. public int getpassword()
  68. {
  69. return this.password;
  70. }
  71.  
  72. }
  73.  
  74. class Auth
  75. {
  76. private int authid;
  77. private int authadd;
  78. private int authdel;
  79. private int authupdate;
  80.  
  81. public void setauthid(int authid)
  82. {
  83. this.authid = authid;
  84. }
  85.  
  86. public int getauthid()
  87. {
  88. return this.authid;
  89. }
  90.  
  91. public void setauthadd(int authadd)
  92. {
  93. this.authadd = authadd;
  94. }
  95.  
  96. public int getauthadd()
  97. {
  98. return this.authadd;
  99. }
  100.  
  101. public void setauthdel(int authdel)
  102. {
  103. this.authdel = authdel;
  104. }
  105.  
  106. public int getauthdel()
  107. {
  108. return this.authdel;
  109. }
  110.  
  111. public void setauthupdate(int authupdate)
  112. {
  113. this.authupdate = authupdate;
  114. }
  115.  
  116. public int getauthupdate()
  117. {
  118. return this.authupdate;
  119. }
  120.  
  121. }
  122.  
  123. class Manue1
  124. {
  125. private int manue1id;
  126. private string manue1name;
  127. private ArraySegment<Manue2> manue2array;
  128.  
  129. public void setmanue1id(int manue1id)
  130. {
  131. this.manue1id = manue1id;
  132. }
  133.  
  134. public int getmanue1id()
  135. {
  136. return this.manue1id;
  137. }
  138.  
  139. public void setmanue1name(string manue1name)
  140. {
  141. this.manue1name = manue1name;
  142. }
  143.  
  144. public string getmanue1name()
  145. {
  146. return this.manue1name;
  147. }
  148.  
  149. }
  150.  
  151. class Manue2
  152. {
  153. private int manue2id;
  154. private string manue2name;
  155.  
  156. public void setmanue2id(int manue2id)
  157. {
  158. this.manue2id = manue2id;
  159. }
  160.  
  161. public int getmanue2id()
  162. {
  163. return this.manue2id;
  164. }
  165.  
  166. public void setmanue2name(string manue2name)
  167. {
  168. this.manue2name = manue2name;
  169. }
  170.  
  171. public string getmanue2name()
  172. {
  173. return this.manue2name;
  174. }
  175.  
  176. }
  177.  
  178. class MainTest
  179. {
  180. /* static void Main(string[] args)
  181. {
  182. //创建it部门
  183. //创建用户
  184. Program p = new Program();
  185. string sql = "SELECT *FROM dept,abc.`user` WHERE dept.`deptid`=1 AND abc.`user`.`deptid`=dept.deptid";
  186. p.getUserData(sql);
  187.  
  188. Console.WriteLine("hello world");
  189. Console.ReadLine();
  190.  
  191. }*/
  192. }

c#类的继承与包含的关系的更多相关文章

  1. Android Studio中查看类的继承关系

    查看类的继承关系的快捷键F4.在Android Studio经常使用快捷键这篇文章中.有写了.今天主要是讲一些关于这个快捷键出来的界面的一些配置.这块功能相对偏冷一些,可能非常多人都会用不到.可是关于 ...

  2. phpstorm查看类的继承关系

    在看一些框架源码时,有些类有很多的继承或者接口,有一款神奇的帮助很重要 选中一个类文件,右键,选择diagrams->show diagrams 即可得到类的继承关系,如上右图 使用函数 fun ...

  3. 游戏编程之Unity常用脚本类的继承关系

    前言学习Unity开发引擎的初学者会接触大量的脚本类,而这些类之间的关系往往容易被忽略.本文对Unity引擎开发中的一些常用类及其关系进行了简单的归纳总结. 博文首发地址:http://tieba.b ...

  4. [Android Studio] Android Studio中查看类的继承关系

    转载自:http://blog.csdn.net/hyr83960944/article/details/38098091 查看类的继承关系的快捷键F4,在Android Studio常用快捷键这篇文 ...

  5. Pycharm 查看一个类的继承关系图

    Pycharm 查看一个类的继承关系图 在我们开发过程中: 无论是使用的开发框架自带的类, 还是我们自定义的类都特别多; 并且类之间单继承和多继承频繁使用, 这个继承,不仅仅是一级的继承关系,包括好几 ...

  6. cc.isChildClassOf 判断两个类的继承关系

    使用 cc.isChildClassOf 来判断两个类的继承关系: var Texture = cc.Class(); var Texture2D = cc.Class({ extends: Text ...

  7. openmax component类的继承关系

    向OpenCORE里继承一个新的codec时,需要用到OpenMAX接口规范对该codec进行封装,即要定义一个用于封装的类(wrapper),实现OpenMAX规定的集中核心方法(omx core  ...

  8. UML类图(上):类、继承和实现

    面向对象设计 对于一个程序员来说,在工作的开始阶段通常都是别人把东西设计好,你来做.伴随着个人的成长,这个过程将慢慢变成自己设计一部分功能来实现,自己实现.如果要自己设计,无论是给自己看,还是给别人看 ...

  9. 【Python五篇慢慢弹(5)】类的继承案例解析,python相关知识延伸

    类的继承案例解析,python相关知识延伸 作者:白宁超 2016年10月10日22:36:57 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给 ...

随机推荐

  1. Djangon 基础总结 汇总 从请求到返回页面的过程,

    第一步我是用户 现在 浏览器上输入地址 ---> 发送给服务   来请求返回当前的页面 第二步  服务端获得我当前的客户端要求访问的地址   第三步 服务端去urls.py中去,来看是要访问那个 ...

  2. svelte 构建快速web 应用的工具

    svelte 和angular vue reat 类似,都是方便快速的创建用户界面,最大不同的地方是svelte 转换你的app 是在构建时,而不是运行时,所以好处就是不用花费太多的操作在,框架的 抽 ...

  3. lapis 项目添加prometheus 监控

      lapis 是基于openresty 扩展的,所以直接将支持prometheus的模块构建进openresty 就可以了 我使用的是nginx-module-vts 模块 环境准备 我已经构建好了 ...

  4. Javascript 中 的 for ... in 和 for ... of 差别

    Javascript 中 的 for ... in 和 for ... of 差别 for ... in 是历史问题,在循环数据时会可以出现奇怪的问题,比如把数据的属性循环出来. for ... of ...

  5. 自动化部署--shell脚本--1

    传统部署方式1.纯手工scp2.纯手工登录git pull .svn update3.纯手工xftp往上拉4.开发给打一个压缩包,rz上去.解压 传统部署缺点:1.全程运维参与,占用大量时间2.上线速 ...

  6. apt-get update 与 apt-get upgrade 的区别

    总而言之,update是更新软件列表,upgrade是更新软件:所以,这两命令都是一块用,update后再upgrade. update 是更新 /etc/apt/sources.list 和 /et ...

  7. create-react-app-typescript 知识点

    github:https://github.com/wmonk/create-react-app-typescript 报错:Import sources within a group must be ...

  8. mobx 知识点

    antd+mobx 项目例子:https://github.com/cag2050/antd_mobx_demo 在 create-react-app 创建的项目中,使用 mobx:https://s ...

  9. bzoj 2553 [BeiJing2011]禁忌——AC自动机+概率DP+矩阵

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2553 看了题解才会…… 首先,给定一个串,最好的划分方式是按禁忌串出现的右端点排序,遇到能填 ...

  10. git 查看提交历史

    查看提交历史 git log 查看每次提交的具体改动内容 git log -p 查看某个文件历次提交的具体改动内容 git log -p <file name> # git log -p ...