C#中的Char.ConvertToUtf32(String,Int32)方法
C#中的Char.ConvertToUtf32(String,Int32)方法用于将字符串中指定位置的UTF-16编码字符或代理对的值转换为Unicode代码点。
语法
以下是语法-
public static int ConvertToUtf32 (string str, int index);
在上面,str是包含字符或代理对的字符串。index参数是字符或代理对在str中的索引位置。
示例
现在让我们看一个实现Char.ConvertToUtf32(String,Int32)方法的示例-
using System;
public class Demo {
public static void Main(){
int utf = 0x046;
string str = Char.ConvertFromUtf32(utf);
Console.WriteLine("Final Value = "+str);
int res = Char.ConvertToUtf32(str, 0);
Console.WriteLine("Actual Value = 0x{0:X}", res);
}
}输出结果
这将产生以下输出-
Final Value = F Actual Value = 0x46
示例
现在让我们来看另一个示例-
using System;
public class Demo {
public static void Main(){
int utf = 0x057;
string str = Char.ConvertFromUtf32(utf);
Console.WriteLine("Final Value = "+str);
int res = Char.ConvertToUtf32(str, 0);
Console.WriteLine("Actual Value = 0x{0:X}", res);
}
}输出结果
这将产生以下输出-
Final Value = W Actual Value = 0x57
热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短