c#字符長度查詢代碼
更新時(shí)間:2012年06月09日 00:24:10 作者:
下面的代碼用了查詢字符串中的一些類型,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
using System;
using System.Text;
namespace StringLengthTest
{
class Program
{
static void Main(string[] args)
{
string strTmp = "abcd1234軟件包";
int i = Encoding.GetEncoding("GB2312").GetBytes(strTmp).Length;
int j = Encoding.Unicode.GetBytes(strTmp).Length;
int m = Encoding.ASCII.GetBytes(strTmp).Length;
int n = Encoding.Default.GetBytes(strTmp).Length;
int k = Encoding.UTF8.GetBytes(strTmp).Length;
Console.WriteLine(strTmp);
Console.WriteLine("GB2312: " + i);
Console.WriteLine("Unicode:" + j);
Console.WriteLine("ASCII: " + m);
Console.WriteLine("Default:" + n);
Console.WriteLine("UTF8: " + k);
Console.ReadKey();
}
}
}
運(yùn)行結(jié)果:
abcd1234軟件包
GB2312: 14
Unicode:22
ASCII: 11
Default:14
UTF8: 17
您可能感興趣的文章:
- C#中遍歷DataSet數(shù)據(jù)集對象實(shí)例
- c#的dataset離線數(shù)據(jù)集示例
- C#中遍歷各類數(shù)據(jù)集合的方法總結(jié)
- 水晶易表調(diào)用C#的WebService,返回?cái)?shù)據(jù)集合的應(yīng)用分析
- C#百萬數(shù)據(jù)查詢出現(xiàn)超時(shí)問題的解決方法
- c#中executereader執(zhí)行查詢示例分享
- c#使用wmi查詢usb設(shè)備信息示例
- c#實(shí)現(xiàn)萬年歷示例分享 萬年歷農(nóng)歷查詢
- C#中Linq查詢基本操作使用實(shí)例
- C# Mysql 查詢 Rownum的解決方法
- C#中使用ADOMD.NET查詢多維數(shù)據(jù)集的實(shí)現(xiàn)方法
相關(guān)文章
C#向PPT文檔插入圖片以及導(dǎo)出圖片的實(shí)例
PowerPoint演示文稿是我們?nèi)粘9ぷ髦谐S玫霓k公軟件之一,本篇文章介紹了C#向PPT文檔插入圖片以及導(dǎo)出圖片的實(shí)例,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。2016-12-12C#基于WebBrowser獲取cookie的實(shí)現(xiàn)方法
這篇文章主要介紹了C#基于WebBrowser獲取cookie的實(shí)現(xiàn)方法,實(shí)例分析了C#基于WebBrowser簡單讀取瀏覽谷歌網(wǎng)站cookie的相關(guān)技巧,非常簡單實(shí)用,需要的朋友可以參考下2015-11-11