zoukankan      html  css  js  c++  java
  • C#字符格式化占位符

    using System;
    using System.Diagnostics;
    using System.Text;
    using System.Collections;
    using System.Collections.Generic;
    
    class Test
    {
        public delegate void deltest(string str);
        public static void Callbk(string str)
        {
            Console.WriteLine(str);
        }
        static void Main()
        {
            byte[] bs = { 97, 98, 99, 100 };
            StringBuilder sb = new StringBuilder();
            for(int i=0; i<bs.Length; ++i)
            {
                sb.Append(bs[i].ToString("x3"));//16进制,占3个字符宽度
                sb.Append(bs[i].ToString().PadLeft(4, '_'));//占4字符宽度,不足用下划线填充
            }
    
            Console.WriteLine(sb); //061062063064
        }
    
    }
  • 相关阅读:
    01Game
    面试题
    面试题
    面向对象笔记
    1212作业
    12011作业
    1210作业
    1206作业
    1205作业
    1204作业
  • 原文地址:https://www.cnblogs.com/timeObjserver/p/6051495.html
Copyright © 2011-2022 走看看