uni1->C#->装箱拆箱
来源:互联网 发布:java老师王克晶年薪 编辑:程序博客网 时间:2024/05/21 20:26
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"><span style="font-size:32px;">C#->装箱拆箱</span></span>
父类
using UnityEngine;using System.Collections;public class Vehicle {private float Speed;private float MaxSpeed;private float Weight;public void Run(){Debug.Log("Vehicle-Run");}public float speed{set{Speed=value;}get{return Speed;}}public float maxspeed{set{MaxSpeed=value;}get{return MaxSpeed;}}public float weight{set{Weight=value;}get{return Weight;}}public void Stop(){Debug.Log("Vehicle-Stop");}}
子类
using UnityEngine;using System.Collections;public class car :Vehicle {public void Run(){Debug.Log("car-Run"+"speed->"+speed+"\t"+"Weight->"+weight+"\t"+"MaxSpeed"+maxspeed);}public void Stop(){Debug.Log("car-Stop"+"speed->"+speed+"\t"+"Weight->"+weight+"\t"+"MaxSpeed"+maxspeed);}}
引用->装箱拆箱
<pre name="code" class="csharp">using UnityEngine;using System.Collections;public class chen : MonoBehaviour {public bicycle s1=new bicycle();public Vehicle s2=new car();//zhuangxiangvoid Start () {s1.speed = 30;s1.maxspeed = 90;s1.weight = 1000;s2.speed = 50;s2.maxspeed = 120;s2.weight = 1500;s1.Run ();s1.Stop ();s2.Run ();s2.Stop ();car c2 = carRun (s2) as car;//chaixiang}Vehicle carRun(Vehicle c){c.Run ();c.maxspeed = 0;return c;}void Update () {}}
0 0
- uni1->C#->装箱拆箱
- C#装箱拆箱
- 【C#】装箱和拆箱
- 【C#】装箱与拆箱
- 【C#】装箱与拆箱
- objective-c 装箱和拆箱
- 装箱与拆箱C#(一)
- 装箱和拆箱(C#)
- 《Effective C#》之减少装箱和拆箱
- 《Effective C#》之减少装箱和拆箱(图)
- C#==>类型转换 与 装箱拆箱
- C#—装箱(boxing)与拆箱(unboxing)
- C#——装箱(boxing)和拆箱(unboxing)
- C# 指南之装箱与拆箱
- [C#] 值类型的装箱和拆箱
- ios学习路线—Objective-C(装箱和拆箱)
- 装箱和拆箱
- 装箱和拆箱
- EditText使用详解-包含很多教程上看不到的功能演示
- 10个无版权限制的免费图片素材资源网站
- 一些linux系统命令
- Android adb命令使用
- 【LeetCode】Linked List Cycle II
- uni1->C#->装箱拆箱
- Git删除空目录
- 硬盘基本知识(磁道、扇区、柱面、磁头数、簇、MBR、DBR)
- Generating SSH keys for github
- tomcat7连接oracle的Connection refused问题解决
- spring3.x使用经验总结
- 个推的使用方法
- SparseArray源码分析(未完)
- Linux cpuinfo 详解