zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    [NOI2010] 能量采集 (数学)
    mysql双主操作记录
    linux查看版本
    netty
    idea修改文件,target目录对应的文件消失
    oracle11g的分区(range、list)索引测试
    There is a cycle in the hierarchy解决办法
    git学习转廖雪峰
    解决SVN Cleanup错误: Failed to run the WC DB work queue associated with
    nginx之 proxy_pass
  • 原文地址:https://www.cnblogs.com/jintuo/p/4151120.html
Copyright © 2011-2022 走看看