string s = “hello world! ni hao!”
char[] ary = s.ToCharArray();
char 是一个数据类型,作用是定义字符型变量(单个或是字符串)。
比方int 是整形数据,int a = 3;这里int 是类型, a 是整型变量,3是赋值;
char s = ‘A’; char是字符类型,s是字符型变量,A是赋值给变量s;
char s[] = “c program”; char是字符类型,s[]是字符型数组,"c program"是赋给数组的值
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
string y = "we we we";
char[] x = y.ToCharArray();
Console.WriteLine(x);
Console.ReadKey();
}
}
}