当前位置: 首页 > news >正文

恒丰建设集团有限公司 网站app推广的常用方法

恒丰建设集团有限公司 网站,app推广的常用方法,网站建设编辑工作总结,给钱做任务的网站C#中的string.Format方法是一个用于格式化字符串的功能强大的方法。它允许您通过将占位符替换为实际的值来创建格式化的字符串。 一、基本语法是#xff1a; string.Format(format, arg0, arg1, arg2, ...) 其中#xff0c; format是一个字符串#xff0c;其中包含要格式…C#中的string.Format方法是一个用于格式化字符串的功能强大的方法。它允许您通过将占位符替换为实际的值来创建格式化的字符串。 一、基本语法是 string.Format(format, arg0, arg1, arg2, ...) 其中 format是一个字符串其中包含要格式化的文本和占位符。占位符使用花括号 {} 括起来并可以包含格式说明符用于定义值的显示方式。arg0, arg1, arg2, ... 是要插入到格式字符串中的参数。这些参数将按照顺序替换占位符 二、基本用法 1、 把相关参数格式化到指定位置。 string name 小明; int age 25; string message string.Format(我是{0}今年{1}岁。, name, age); Console.WriteLine(message);// 我是小明今年25岁。2、格式化数字 int number 12345; string formattedNumber string.Format({0:N}, number); Console.WriteLine(formattedNumber);// 12,345.00 3、使用命名参数 string firstName 王; string lastName 小小; string fullName string.Format(我的名字是{firstName} {lastName}。, new { firstName, lastName }); Console.WriteLine(fullName);// 我的名字是王小小。4、格式化日期 DateTime currentDate DateTime.Now; string formattedDate string.Format(Today is {0:yyyy-MM-dd}., currentDate); Console.WriteLine(formattedDate);//Today is 2023-11-23.三、常见的一些占位符的使用。 1、{0} - 将第一个参数的值插入到占位符中{1}{2}...类推。 string name John; string message string.Format(Hello, {0}!, name); Console.WriteLine(message); //Hello, John! 2、{{0:#.##} - 将第一个参数的值按照指定的数值格式进行格式化 double number 123.456; string formattedNumber string.Format(The number is {0:0.00}., number); Console.WriteLine(formattedNumber); //The number is 123.46. 3、{0,-10}{0,10} - 将第一个参数的值插入到占位符中并左对齐、右对齐总宽度为10个字符 string name Bob; string formattedName string.Format(Name: {0,-10}., name);//左对齐 Console.WriteLine(formattedName); //Name: Bob . 4、{0:G} - 将第一个参数的值按照一般格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Current date and time: {0:G}., now); Console.WriteLine(formattedDate); //Current date and time: 11/23/2023 9:28:46 PM. 5、{{0:C} - 将第一个参数的值按照货币格式进行格式化输出人民币还是美元跟系统有关 decimal price 99.99m; string formattedPrice string.Format(Price: {0:C}., price); Console.WriteLine(formattedPrice); // Price: $99.99. 6、{0:E} - 将第一个参数的值按照科学计数法格式进行格式化 double number 12345.6789; string formattedNumber string.Format(Number: {0:E}., number); Console.WriteLine(formattedNumber); //Number: 1.234568E004. 7、{0:X} - 将第一个参数的值按照十六进制格式进行格式化 int number 255; string formattedNumber string.Format(Number: {0:X}., number); Console.WriteLine(formattedNumber); //Number: FF. 8、{0:P} - 将第一个参数的值按照百分比格式进行格式化 9、{0:text} - 将第一个参数的值插入到占位符中并使用指定的文本包围 10、{0:0} - 将第一个参数的值按照整数格式进行格式化 11、一些格式化日期的占位符的使用 {0:D} - 将第一个参数的值按照长日期格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Todays date: {0:D}., now); Console.WriteLine(formattedDate); //Todays date: Sunday, November 23, 2023. {0:d} - 将第一个参数的值按照短日期格式进行格式化  DateTime now DateTime.Now; string formattedDate string.Format(Todays date: {0:d}., now); Console.WriteLine(formattedDate); //Todays date: 11/23/2023. {0:T} - 将第一个参数的值按照长时间格式进行格式化 DateTime now DateTime.Now; string formattedTime string.Format(Current time: {0:T}., now); Console.WriteLine(formattedTime); //Current time: 9:28:46 PM. {0:t} - 将第一个参数的值按照短时间格式进行格式化 DateTime now DateTime.Now; string formattedTime string.Format(Current time: {0:t}., now); Console.WriteLine(formattedTime); //Current time: 9:28 PM. {0:F} - 将第一个参数的值按照完整日期和时间格式进行格式化 DateTime now DateTime.Now; string formattedDateTime string.Format(Current date and time: {0:F}., now); Console.WriteLine(formattedDateTime); //Current date and time: Sunday, November 23, 2023 9:28:46 PM.{0:M} - 将第一个参数的值按照月份和日期格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Todays date: {0:M}., now); Console.WriteLine(formattedDate); //Todays date: November 23. {0:Y} - 将第一个参数的值按照年份和月份格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Current month and year: {0:Y}., now); Console.WriteLine(formattedDate); //Current month and year: November 2023. {0:y} - 将第一个参数的值按照年份和月份格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Current month and year: {0:y}., now); Console.WriteLine(formattedDate); //Current month and year: November 2023.{0:g} - 将第一个参数的值按照一般短日期和时间格式进行格式化 DateTime now DateTime.Now; string formattedDateTime string.Format(Current date and time: {0:g}., now); Console.WriteLine(formattedDateTime); //Current date and time: 11/23/2023 9:28 PM.{0:yyyy-MM-dd} {0:yyyyMMddHHmmss}- 将第一个参数的值按照指定的日期格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Todays date: {0:yyyy-MM-dd}., now);//Todays date: 2023-11-23. string formattedDate1 string.Format({0:yyyyMMdd}., now);//20231123212846 {0:HH:mm:ss} - 将第一个参数的值按照指定的时间格式进行格式化 DateTime now DateTime.Now; string formattedTime string.Format(Current time: {0:HH:mm:ss}., now); Console.WriteLine(formattedTime); //Current time: 21:28:46. {0:dddd, MMMM dd, yyyy} - 将第一个参数的值按照指定的完整日期格式进行格式化 DateTime now DateTime.Now; string formattedDate string.Format(Todays date: {0:dddd, MMMM dd, yyyy}., now); Console.WriteLine(formattedDate); //Todays date: Sunday, November 23, 2023.{0:hh:mm tt} - 将第一个参数的值按照指定的12小时制时间格式进行格式化 DateTime now DateTime.Now; string formattedTime string.Format(Current time: {0:hh:mm tt}., now); Console.WriteLine(formattedTime); //Current time: 09:28 PM.{0:yyyy-MM-dd HH:mm:ss} - 将第一个参数的值按照指定的日期和时间格式进行格式化 DateTime now DateTime.Now; string formattedDateTime string.Format(Current date and time: {0:yyyy-MM-dd HH:mm:ss}., now); Console.WriteLine(formattedDateTime); //Current date and time: 2023-11-23 21:28:46.
http://www.yutouwan.com/news/83311/

相关文章:

  • 北京sem网站电商的推广方式
  • 阿里云网站商城建设wordpress 首页打不开
  • 动易论坛官方网站阿里云域名注册及备案
  • 免费建站模板哪个好wordpress 爆破
  • 十堰网站优化湛江百度网站快速排名
  • 可以在线做试卷的网站医院信息化建设会议安排网站
  • 围场网站建设网络公司是做什么的?
  • 手机网站seo网站建设 ipc备案
  • 新网站外链怎么做国外做储物的网站
  • 重庆网站建设索q479185700自己想做个网站
  • 小米路由器mini做网站响应式网站怎么做
  • 网站服务器免费吗最近七天的新闻大事
  • 网站建设横幅标语网站空间租用哪个好
  • 新的网站后台不显示网站栏目软文500字范文
  • 微信网站建设知识上海共有多少家企业
  • wordpress页面可视编辑wordpress seo自定义
  • 网站上传权限芜湖公司做网站
  • 庆阳网站设计报价网站设计能出来什么
  • 张家港高端网站建设16素材网
  • 广东企业备案 网站建设方案书口碑好的移动网站建设
  • 折再返怎么 做网站网站建设工作的作用
  • seo百度网站排名研究中心关键词首页优化移动端网站宽度做多大
  • 国外免费搭建网站源码wordpress 主题 her
  • 快速建设企业网站vs网站开发建表怎么肩啊
  • 灵璧哪有做网站的建站工具介绍
  • dw旅游网站模板超级优化大师
  • 做网站好还是做app好广州网站优化公司
  • 自己做网站需要做啥青岛市黄岛区建设局网站
  • 怎么弄公司网站搜狗指数官网
  • 爱射影院网站建设中杭州营销型网站建设