在C#中,字符串可以通过以下几种方式进行创建和初始化:
string str = "Hello, World!";
string str1 = "Hello, ";
string str2 = "World!";
string result = str1 + str2;
string name = "Alice";
int age = 30;
string message = $"My name is {name} and I am {age} years old.";
string str = new string('a', 5); // 创建包含5个字符'a'的字符串