当前位置:网站首页>C# 之 $ – 字符串内插
C# 之 $ – 字符串内插
2022-07-30 08:32:00 【InfoQ】
class Program
{
static void Main(string[] args)
{
DateTime date = DateTime.Now;
//我们通常是这么写,
Console.WriteLine("今天是{0}年{1}月{2}日", date.Year, date.Month, date.Day);
//$ 的用法
Console.WriteLine($"今天是{date.Year}年{date.Month}月{date.Day}日");
Console.WriteLine($"这是$内插时{{转译大括号}}");
}
}


class Program
{
static void Main(string[] args)
{
//$"{"String",正数右间距,负数左间距}|{"String",10}"
Console.WriteLine($"{"|Czhen",-10}|{"ya",10}|");
}
}

class Program
{
static void Main(string[] args)
{
Console.WriteLine(" ___________________");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine("|_________|_________|");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine($"{"|",-10}|{"|",10}");
Console.WriteLine("|_________|_________|");
}
}

边栏推荐
猜你喜欢

Apache DolphinScheduler's new generation of distributed workflow task scheduling platform in practice - Part 1

hicp第六天

基于JSP实现校园二手交易平台

【Flask框架②】——第一个Flask项目

How to Assemble a Registry

新手必备!最全电路基础知识讲解

电源完整性的去耦和层间耦合电容

虚幻引擎图文笔记:could not be compiled. Try rebuilding from source manually.问题的解决

用示波器揭示以太网传输机制

Access to display the data
随机推荐
qsort 函数的使用及其模拟实现
TreeSet parsing
最右的一道面试算法题,--特殊基因
【Flask框架②】——第一个Flask项目
分布式系统大势所趋,银行运维如何与时俱进?
hcip第八天
智能存储柜——解决您的存储需求
公共Jar包的版本管理
【愚公系列】2022年07月 Go教学课程 021-Go容器之切片操作
都说FPGA高端,它到底能干啥?
[Unity]UI切换环形滚动效果
[Fun BLDC series with zero basics] Taking GD32F30x as an example, the timer related functions are explained in detail
jdbc ResultSetMetaData获取tableName问题
EMC过不了?都是PCB工程师的锅?
最远点采样 — D-FPS与F-FPS
Integral Special Notes - Definition of Integral
涛思 TDengine 2.6+优化参数
2022杭电多校第一场
The sword refers to offer 48: the longest non-repeating substring
Webview中的超链接点击到外部浏览器打开