温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Csharp数据格式初体验

发布时间:2020-04-09 18:39:19 来源:网络 阅读:443 作者:phize 栏目:建站服务器

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 数字格式化
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 220;
            Console.WriteLine("i = {0}",i);
            int j = 25;
            Console.WriteLine("j = {0}",j);
            Console.WriteLine();
            /*{参数,占位符(多少个空格)}*/
            Console.WriteLine("{0,6}\n+{1,5}\n-------\n{2,6}",i,j,i+j);
            /*
            i = 220
            j = 25

                220
            +   25
            -------
                245

             */
            decimal m = 19.23m;
            decimal n = 73.7m;
            Console.WriteLine("我现在有{0,5:C2}",m);
            Console.WriteLine("然后有{0,7:C2}",n);
            Console.WriteLine("{0,8:C2}\n+\n{1,7:C2}\n----------\n{2,8:C2}\n",m,n,m+n);
            Console.ReadLine();
        }
    }
}
/*
i = 220
j = 25

   220
+   25
-------
   245
我现在有¥19.23
然后有 ¥73.70
  ¥19.23
+
 ¥73.70
----------
  ¥92.93

 
*/

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI