zoukankan      html  css  js  c++  java
  • C#笔记(二)——输入输出函数

    一:输入函数:

    1:

    string a = Console.ReadLine(); 将输入的字符串放入变量a中;

    2:

     int a = Console.Read(); 将输入的字符串的第一个字符的ASC码存入整形变量a中;

    二:换行(在下一行执行):       Console.WriteLine();

     输入: int a = 9;
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine(a);

    三:格式化输出

      a: 输入:

         int a = 1;int b = 2;int c = 3;
                Console.WriteLine("a={0},b={1},c={2}",a,b,c);

          输出:

               

      b:输入:

                float score = 23.5f;
                //f表示小数点后保留几位,后面可以加数字
                Console.WriteLine("score={0:F2}", score);
                Console.WriteLine("score={0:0.000}", score);

          输出:


       c:输入

                //把数据转换成%形式,并保留两个小数位
                Console .WriteLine("{0:p2}" , 1 / 4f);
                //如果字符串前面加@,则字符串里面的转义字符失效
                Console .Write(@"lanoukeji " );
                Console .Write("hello world" );
     


              

  • 相关阅读:
    3.3 React Hooks
    ES6高阶函数
    ES6扩展运算符
    4.0不用npm,cnpm。使用yarn包启动react项目
    4.3 webpack打包学习
    4.2 Node.js模块化教程
    4.1React模块化
    vue组件化开发
    js箭头函数
    weblogic_exploit
  • 原文地址:https://www.cnblogs.com/ningyongbin/p/5922028.html
Copyright © 2011-2022 走看看