C#控制台基础 console.writeline中写加号为何能连接多个字符串之string.concat

1、代码

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6
 7 namespace ConsoleApplication3
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             int num1 = 10;
14             int num2 = 10;
15             double num3 = 10.1;
16
17             Console.WriteLine(num1.ToString()+num2.ToString()+num3.ToString());
18             Console.ReadKey();
19         }
20     }
21 }

2、效果

咱们用反编译看看代码,

C#看不出来什么,转到IL语言

看了那个string::concat了吗,这就是cw中的+可以连接字符串的原因了。

时间: 2024-07-29 18:37:34

C#控制台基础 console.writeline中写加号为何能连接多个字符串之string.concat的相关文章

oc将字符串中单词按照出现次数(次数都不一样)降序排序,排序之后单词只出现一次,源字符串中单词用下划线连接,生成字符串也用下滑线连接

/* 将字符串中单词按照出现次数(次数都不一样)降序排序,排序之后单词只出现一次,源字符串中单词用下划线连接,生成字符串也用下滑线连接(10分) 如传入:@"good_good_study_good_study" 返回:@"good_study" 如传入:@"I_love_I_hate_love_love" 返回:@"love_I_hate" */ 方法1:选择排序 -(NSString *)sortStringByNumbe

C#控制台基础 提取出中x年x月x日的年数,月数,日数

1.代码 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApplication2 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 string nowTime =

JavaSE8基础 子类构造函数中写super语句去显式指定父类的构造函数

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        代码: /* *默认是 子类的构造函数先去调用父类的无参构造函数,但是问题就来,如果父类没有无参构造函数怎么办? *通过super去显式指定父类的构造函数 */ //父类 class Father { //有参构造函数,int public Father(int num) { System.out.println("

C#中Console.WriteLine()函数输出格式详解

格式项都采用如下形式: {index[,alignment][:formatString]} 其中"index"指索引占位符,这个肯定都知道: ",alignment"按字面意思显然是对齐方式,以","为标记: ":formatString"就是对输出格式的限定,以":"为标记. alignment:可选,是一个带符号的整数,指示首选的格式化字段宽度.如果“对齐”值小于格式化字符串的长度,“对齐”会被忽略,

C#控制台基础 string.concat连接多个int类型与double类型变量

1.代码 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ConsoleApplication3 8 { 9 class Program 10 { 11 static void Main(string[] args) 12 { 13 int num1 = 10; 14

WriteLine(ls.ToString());Console.WriteLine(ls);输出结果相同,为什么要加 .ToString()

1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace Test05 7 { 8 class Program 9 { 10 static void Main(string[] args) 11 { 12 int shj1 = 45; //声明整型变量shj1,并赋值为45 13 int shj2 = 5; //声明整型变量shj2,并赋值

C#控制台基础 streamreader与streamwriter读取一个txt中的内容写到另外一个txt中

1 代码 1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace ConsoleApplication4 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 {

C#控制台基础 在博客备份xml文件中提取所有博文的标题 (正则,流读取)

镇场诗: 清心感悟智慧语,不着世间名与利.学水处下纳百川,舍尽贡高我慢意. 学有小成返哺根,愿铸一良心博客.诚心于此写经验,愿见文者得启发.------------------------------------------ introduction: 解析 博客园-博客备份 生成的XML文件,获得所有博文的标题. code: 1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System

C#控制台基础 path.changeextension一个路径字符串中的文件扩展名

将一个txt文件,改成exe 0.文件 1.代码 1 using System; 2 using System.Collections.Generic; 3 using System.IO; 4 using System.Linq; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace ConsoleApplication4 9 { 10 class Program 11 { 12 static void Main(