C# 数据类型与字符串操作全面解析
1. 变量声明
在 C# 中,我们可以在同一行代码中声明多个相同基础类型的变量。例如下面的三个布尔变量:
static void LocalVarDeclarations()
{
Console.WriteLine("=> Data Declarations:");
int myInt = 0;
string myString;
myString = "This is my character data";
// Declare 3 bools on a single line.
bool b1 = true, b2 = false, b3 = b1;
Console.WriteLine();
}
同时,C# 的 bool 关键字是 System.Boolean 结构的简写,我们也可以使用其完整名称来声明变量。以下是 LocalVarDeclarations() 方法的最终实现,展示了多种声明局部变量的方式:
static void LocalVarDeclarations()
{
Console.WriteLine("=> Data Declarations:");
// Local variables are declared and initialized as follows:
// dataTyp
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



