2014-12-08 C#基础

---恢复内容开始---

//注释一行
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//命名空间
namespace firstDebug
{
    //类
    class Program
    {
        //主函数,一整个项目,有且只有一个主函数,它是程序的入口
        static void Main(string[] args)
        {
            //开始写代码

           //数据类型 变量名=值;

            int i=0;

            //可以分开写

           //int s;

            s=1;

           //同时定义多个

           int a,b,c;

           b=3;

           //

           double d=1.23d;---结尾加d表示为double类型

           float f=1.23f;

           decimal m=1.23m;

           //

           bool bo=true;

          //

          string s1="你好";

            Console.WriteLine(i);
            Console.ReadLine();
        }
    }
}

类的颜色:深蓝色

常量:const+某个数据类型

例如 const double d=1.23 (×)

常量不被赋值,只可以被引用

 

类型转换:

int i=4;

int s=5;

double jieguo=(double)i/s;  (在变量前直接加小括号转换为强制转换,只能为double,int,decimal)

string ss=i.ToString();  (将 i 转化为string类型)

 

string s1="3.5";

double dd=double.Parse(s1);      //将s1转化为double类型

或者:double ds=Convert.ToDouble(s1);

posted @ 2014-12-08 15:01  雪山飞驴  阅读(109)  评论(0编辑  收藏  举报