using System;
class Test
{
static void Main()
{
char c='A';
Console.WriteLine((char)65);//強制類型轉換
Console.WriteLine(Convert.ToChar(65));//這种方法速度不及強制類型轉換
}
}
class Test
{
static void Main()
{
char c='A';
Console.WriteLine((char)65);//強制類型轉換
Console.WriteLine(Convert.ToChar(65));//這种方法速度不及強制類型轉換
}
}
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 2008/8/26
* Time: 下午 11:36
* char是System.Char的一個實例,是值類型的.
* 字符Char,下面的例子是打印0-127r ascii編碼
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
class test
{
static void Main()
{
for(int i=0;i<127;i++)
{
if(i%10==0)
{
Console.WriteLine();
}
Console.Write("{0,3}:{1,-3}",i,(char)i);
}
}
}
* Created by SharpDevelop.
* User: Administrator
* Date: 2008/8/26
* Time: 下午 11:36
* char是System.Char的一個實例,是值類型的.
* 字符Char,下面的例子是打印0-127r ascii編碼
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
class test
{
static void Main()
{
for(int i=0;i<127;i++)
{
if(i%10==0)
{
Console.WriteLine();
}
Console.Write("{0,3}:{1,-3}",i,(char)i);
}
}
}
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 2008/8/26
* Time: 下午 11:54
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
//通過十六進制的unicode編碼輸出"你好"
using System;
class test
{
static void Main()
{
Console.WriteLine("\u4F60\u597D");
}
}
* Created by SharpDevelop.
* User: Administrator
* Date: 2008/8/26
* Time: 下午 11:54
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
//通過十六進制的unicode編碼輸出"你好"
using System;
class test
{
static void Main()
{
Console.WriteLine("\u4F60\u597D");
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace ShowUFT8
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
//前面的部份省略,關鍵是下面這一部份
//輸出unicode編碼
void Button1Click(object sender, EventArgs e)
{
System.Text.StringBuilder s=new System.Text.StringBuilder(0xFFFF*3);
for(int i=128;i<0xFFFF;i++)
{
if(i%50==0)
s.Append("\r\n");
s.AppendFormat("{0,3}",(char)i);
this.textBox1.Text=s.ToString();
}
}
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace ShowUFT8
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
//前面的部份省略,關鍵是下面這一部份
//輸出unicode編碼
void Button1Click(object sender, EventArgs e)
{
System.Text.StringBuilder s=new System.Text.StringBuilder(0xFFFF*3);
for(int i=128;i<0xFFFF;i++)
{
if(i%50==0)
s.Append("\r\n");
s.AppendFormat("{0,3}",(char)i);
this.textBox1.Text=s.ToString();
}
}
}
}
using System;
class Test
{
static void Main()
{
Console.WriteLine("請輸入一個字符:");
char a;
a=Convert.ToChar(Console.ReadLine());
int i=(int)a;
//漢字是從0x4e00~0x9fa5
if(i<0x4e00 || i>0x9fa5)
Console.WriteLine("不是一個漢字");
else
Console.WriteLine("是一個漢字");
//char.IsLetter(a)char下有一些方法可以驗證是否是字母/數字![](https://www.cnblogs.com/Images/dot.gif)
}
}
class Test
{
static void Main()
{
Console.WriteLine("請輸入一個字符:");
char a;
a=Convert.ToChar(Console.ReadLine());
int i=(int)a;
//漢字是從0x4e00~0x9fa5
if(i<0x4e00 || i>0x9fa5)
Console.WriteLine("不是一個漢字");
else
Console.WriteLine("是一個漢字");
//char.IsLetter(a)char下有一些方法可以驗證是否是字母/數字
![](https://www.cnblogs.com/Images/dot.gif)
}
}