using System;
class Program
{
static void Main()
{
// 输出简单的文本到控制台
Console.WriteLine("Hello, World!");
// 输出变量的值
int number = 42;
Console.WriteLine("The number is: " + number);
// 使用格式化字符串输出
string name = "Alice";
int age = 30;
Console.WriteLine("Name: {0}, Age: {1}", name, age);
// 使用插值字符串输出 (C# 6.0 及以上版本)
Console.WriteLine($"Name: {name}, Age: {age}");
}
}
Console.WriteLine 中传递字符串即可输出文本。+) 或者格式化字符串来输出变量的值。{0}, {1} 等占位符来指定输出顺序,并通过逗号分隔参数传递给 Console.WriteLine。$ 符号,可以直接在字符串中嵌入变量,语法更简洁。上一篇:c# 读取配置文件
下一篇:c# 配置文件
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站