using System;
namespace ConsoleApplication2
{
class Program
{
/**
* 字符和字符串的关系:字符串可以看成是只读字符数组
*/
static void Main(string[] args)
{
char c = 'a';
char c2 = '中';
// char c3 = 'fdf'; error
// char c4 = ''; error
string s = "a";
string s2 = "";
string s3 = "fdf";
string s4 = "我是中国人";
char s5 = s4[0];
Console.WriteLine(s5);
// s4[0] = '你'; error.他是只读的
Console.WriteLine("------------------------------");
foreach(char s44 in s4)
{
Console.WriteLine(s44);
}
Console.WriteLine("------------------------------");
for (int i = s4.Length - 1; i >= 0; i -- )
{
Console.WriteLine(s4[i]);
}
Console.ReadKey();
}
}
}
字符和字符串的关系:字符串可以看成是只读字符数组
最新推荐文章于 2022-12-05 12:38:50 发布