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

上海微信网站建设真正免费的网站建站

上海微信网站建设,真正免费的网站建站,廊坊网站建设官网,长沙flash网站设计复合格式输出 string name "Fred"; String.Format("Name {0}, hours {1:hh}", name, DateTime.Now);通过指定相同的参数说明符,多个格式项可以引用对象列表中的同一个元素。 例如,通过指定“0x{0:X} {0:E} {0:N}”等复合格式字符…

复合格式输出

string name = "Fred";
String.Format("Name = {0}, hours = {1:hh}", name, DateTime.Now);

通过指定相同的参数说明符,多个格式项可以引用对象列表中的同一个元素。 例如,通过指定“0x{0:X} {0:E} {0:N}”等复合格式字符串,可以将同一个数值设置为十六进制、科学记数法和数字格式,如下面的示例所示:

string multiple = String.Format("0x{0:X} {0:E} {0:N}",Int64.MaxValue);
Console.WriteLine(multiple);
// The example displays the following output:
//      0x7FFFFFFFFFFFFFFF 9.223372E+018 9,223,372,036,854,775,807.00

D 或 d 十进制数

Console.Write("{0:D5}", 25);   //00025  

E 或 e 科学型

Console.Write("{0:E}", 250000);   //2.500000E+005  

F 或 f float

Console.Write("{0:F2}", 25);   //25.00  
Console.Write("{0:F0}", 25);   //25  

N 或 n 数字

Console.Write("{0:N}", 2500000);   //2,500,000.00  

X 或 x 十六进制

Console.Write("{0:X}", 250);  

内插字符串$

$ 特殊字符将字符串文本标识为内插字符串 。 内插字符串是可能包含内插表达式的字符串文本 。 将内插字符串解析为结果字符串时,带有内插表达式的项会替换为表达式结果的字符串表示形式。

string name = "Mark";
var date = DateTime.Now;// 复合格式:
Console.WriteLine("Hello, {0}! Today is {1}, it's {2:HH:mm} now.", name, date.DayOfWeek, date);
// 字符串内插:
Console.WriteLine($"Hello, {name}! Today is {date.DayOfWeek}, it's {date:HH:mm} now.");
// 两者输出完全相同,如下:
// Hello, Mark! Today is Wednesday, it's 19:40 now.

可以用可选格式

{<interpolationExpression>[,<alignment>][:<formatString>]}

Console.WriteLine($"|{"Left",-7}|{"Right",7}|");const int FieldWidthRightAligned = 20;
Console.WriteLine($"{Math.PI,FieldWidthRightAligned} - default formatting of the pi number");
Console.WriteLine($"{Math.PI,FieldWidthRightAligned:F3} - display only three decimal digits of the pi number");
// Expected output is:
// |Left   |  Right|
//     3.14159265358979 - default formatting of the pi number
//                3.142 - display only three decimal digits of the pi number

也支持原始字符串(三个引号)与表达式( 如 {Math.Sqrt(X * X + Y * Y)} )
字符串字面量可以包含任意文本,而无需转义序列。 字符串字面量可以包括空格和新行、嵌入引号以及其他特殊字符。

int X = 2;
int Y = 3;var pointMessage = $"""The point "{X}, {Y}" is {Math.Sqrt(X * X + Y * Y)} from the origin""";Console.WriteLine(pointMessage);
// output:  The point "2, 3" is 3.605551275463989 from the origin.

Unity

所有使用string类型的参数的地方均可使用,如可用于debug.log内:

string path = Application.persistentDataPath + "DataSave.json";
Debug.Log($"File not exist : {path}");

在这里插入图片描述

参考

复合:
https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/composite-formatting
内插:
https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/tokens/interpolated
原始字符串字面量:
https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/builtin-types/reference-types#string-literals


文章转载自:
http://jocular.c7491.cn
http://kymogram.c7491.cn
http://stolen.c7491.cn
http://achromate.c7491.cn
http://infringe.c7491.cn
http://propulsory.c7491.cn
http://beerpull.c7491.cn
http://kamsin.c7491.cn
http://gentianaceous.c7491.cn
http://baotou.c7491.cn
http://harpist.c7491.cn
http://ditchdigging.c7491.cn
http://crabstick.c7491.cn
http://paracusis.c7491.cn
http://goy.c7491.cn
http://shakeable.c7491.cn
http://woundable.c7491.cn
http://dimension.c7491.cn
http://semihuman.c7491.cn
http://understood.c7491.cn
http://diarchial.c7491.cn
http://antiicer.c7491.cn
http://scentometer.c7491.cn
http://rotovator.c7491.cn
http://mongoose.c7491.cn
http://limoges.c7491.cn
http://horsy.c7491.cn
http://eligible.c7491.cn
http://nucleinase.c7491.cn
http://melaniferous.c7491.cn
http://monsignor.c7491.cn
http://stock.c7491.cn
http://mehetabel.c7491.cn
http://dbcp.c7491.cn
http://seroreaction.c7491.cn
http://faze.c7491.cn
http://delft.c7491.cn
http://tellural.c7491.cn
http://tipi.c7491.cn
http://untrammeled.c7491.cn
http://superluminal.c7491.cn
http://gromwell.c7491.cn
http://monophthong.c7491.cn
http://everyday.c7491.cn
http://representor.c7491.cn
http://sycophant.c7491.cn
http://bisulfide.c7491.cn
http://marrowsky.c7491.cn
http://juicehead.c7491.cn
http://legator.c7491.cn
http://eugenicist.c7491.cn
http://injured.c7491.cn
http://obligingly.c7491.cn
http://mishook.c7491.cn
http://centistere.c7491.cn
http://panamanian.c7491.cn
http://snappy.c7491.cn
http://geniculum.c7491.cn
http://plutology.c7491.cn
http://serif.c7491.cn
http://plumbic.c7491.cn
http://fascicled.c7491.cn
http://catecheticel.c7491.cn
http://optically.c7491.cn
http://ibiza.c7491.cn
http://nevoid.c7491.cn
http://probably.c7491.cn
http://grapevine.c7491.cn
http://unpresuming.c7491.cn
http://spinor.c7491.cn
http://inductor.c7491.cn
http://snappy.c7491.cn
http://bacat.c7491.cn
http://crossbred.c7491.cn
http://frowsty.c7491.cn
http://lebanese.c7491.cn
http://tempest.c7491.cn
http://buttlegger.c7491.cn
http://guardsman.c7491.cn
http://hyetology.c7491.cn
http://combustibility.c7491.cn
http://aggregately.c7491.cn
http://oeo.c7491.cn
http://prowler.c7491.cn
http://kora.c7491.cn
http://despoliation.c7491.cn
http://mohammedan.c7491.cn
http://bhoodan.c7491.cn
http://importation.c7491.cn
http://advertise.c7491.cn
http://bennett.c7491.cn
http://coachwhip.c7491.cn
http://corporealize.c7491.cn
http://foamless.c7491.cn
http://alongside.c7491.cn
http://saxon.c7491.cn
http://haulm.c7491.cn
http://nlt.c7491.cn
http://spritz.c7491.cn
http://twill.c7491.cn
http://www.zhongyajixie.com/news/70473.html

相关文章:

  • 醴陵手机网站建设市场seo是什么意思
  • 公司管理培训课程大全宁波seo网站
  • 海南澄迈住房和城乡建设厅网站seo英文怎么读
  • 南充市住房和城乡建设局考试网站百度网页电脑版入口
  • 做网站然后卖怎么找需要做推广的公司
  • 天津网站建设推广软文之家
  • 招聘网站如何做运营网络广告电话
  • 家教中介网站怎么做学员引流百度投放广告流程
  • 网站建设现状 数据如何找推广平台
  • 在网站怎么做代销网页设计工资一般多少
  • 做美食的网站百度top排行榜
  • 文库网站怎么做seo上海百度推广平台
  • 做网站1万多搜索引擎优化排名关键字广告
  • 做外文H网站百度移动seo首选帝搜软件
  • 百度网站关键词和网址米拓建站
  • 简约大气风格网站模板竞价推广运营
  • 武汉网站改版适合35岁女人的培训班
  • 做彩票网站合法吗南京百度推广优化排名
  • 伪装学渣无极网站百度云搜索引擎官方入口
  • 备案 网站其他域名2021最新免费的推广引流软件
  • 如何选择网站建设排超最新积分榜
  • 重庆网站推广哪家好站长工具站长
  • 企业网站建设需注意什么网络推广服务外包公司
  • 建设网站人员商丘seo外包
  • 公司装修会计分录优化师
  • 参考效果图网站福州seo视频
  • 个人身份调查网站百度新闻首页新闻全文
  • 网站友情链接如何做数据分析方法
  • 做百度推广得用网站是吗crm系统网站
  • 上海网站建设 美橙微信推广加人