C#基础(基于unity的运用)

输入和输出:

print(1);

print("23456");//只能在继承MonoBehaviour环境中使用

Debug.Log(1);//在任意环境中可以输出

Debug.LogWarning("")//警告

Debug.LogError(“”);//在日志里面显示 错误


数据类型:

bool 类型常用于判断是否正确。//bool res= 100>78;会返回ture

float 浮点型   float hp2=3,4f;//注意f

char 字符型;

string name ="绝地武士";字符串型


字符串相加:

string str1="aaa";

string str2="bbb";

string strRes=str1+str2;

print(strRes);


循环语句:

if(){}else{}语句;

for()循环,       

    // 遍历数组

      for(int i=0;i<hps.Length;i++)

      {

            print(hps[1]);

      }

switch() case;语句


switch(heroType)

{

    case 0:print();break;

    case 1:print();break;

    defalt;break;

}


while()



数组:

声明数组   法1:类型 [] 数组名={数组值}           //            int [] hps={10,20,10};

                 法二:int[] hps=new int [20];//数组长度为20;使用这种方式会使用默认值0初始化。</

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值