易截截图软件、单文件、免安装、纯绿色、仅160KB

C#中一些字符串操作的常用用法,c#编码和解码

//获得汉字的区位码
  byte[] array = new byte[2];
  array = System.Text.Encoding.Default.GetBytes("啊");
int i1 = (short)(array[0] - ''\0'');
  int i2 = (short)(array[1] - ''\0'');
//unicode解码方式下的汉字码
  array = System.Text.Encoding.Unicode.GetBytes("啊");
  i1 = (short)(array[0] - ''\0'');
  i2 = (short)(array[1] - ''\0'');
//unicode反解码为汉字
  string str = "4a55";
  string s1 = str.Substring(0,2);
  string s2 = str.Substring(2,2);
int t1 = Convert.ToInt32(s1,16);
  int t2 = Convert.ToInt32(s2,16);
array[0] = (byte)t1;
  array[1] = (byte)t2;
string s = System.Text.Encoding.Unicode.GetString(array);
//default方式反解码为汉字
  array[0] = (byte)196;
  array[1] = (byte)207;
  s = System.Text.Encoding.Default.GetString(array);
//取字符串长度
  s = "iam方枪枪";
  int len = s.Length;//will output as 6
  byte[] sarr = System.Text.Encoding.Default.GetBytes(s);
  len = sarr.Length;//will output as 3+3*2=9
//字符串相加
  System.Text.StringBuilder sb = new System.Text.StringBuilder("");
  sb.Append("i ");
  sb.Append("am ");
  sb.Append("方枪枪");
/////////////////////////////////////////////////////////////////////
string --> byte array
byte[] data=Syste.Text.Encoding.ASCII.GetBytes(string);
string --> byte
byte data = Convert.ToByte(string);
byte[]-->string
string string = Encoding.ASCII.GetString( bytes, 0, nBytesSize );
 
C# URL编码与解码
--------------------------------------------------------------------------------
 
最近做了一个网站统计分析系统,特别在搜索引擎分析那一部分费了不少时间,从已编码的URL中提取搜索关键词再进行解码。主流的搜索引擎中,URL所使用的字符编码都不同,比如,baidu默认是gb2312,google默认是utf-8。而百度用户可以指定utf-8编码。以这两个搜索引擎分析,URL可能是gb2312,也可能是utf-8。头大了!经过几番琢磨。得出一个暂时可以对付的简单方法。
以下是引用片段:
//oStr是UrlEncode编码字符串
Encoding gb2312 = Encoding.GetEncoding("gb2312"); 


相关文档:

c# 支持XML序列化的泛型 Dictionary

/// <summary>
/// 支持XML序列化的泛型 Dictionary
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <typeparam name="TValue"></typeparam>
[XmlRoot("SerializableDictionary")]
public class SerializableDictionary<TKey, TValue& ......

C compiler cannot create executables的解决方法

搞了几天的问题。编译一个文件时,老是出下面这个错.
checking for C compiler default output file name… configure: error: C compiler cannot create executables
没法子,找高人帮我处理,哈哈….记录下来.因为64位的机器,默认对CFLAGS的这是进行了设置,所以使用下面的命令清空他就行了,这样软件就不会报 ......

C#中string作为引用类型与类的区别的一个问题

RT。先贴代码
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Value_Ref_test1
{
class Program
{
static void Main(string[] args)
{
point a = new point (10,10) ;
point b = a;
......

C#中ref参数与out参数的区别

先贴代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ref_and_Out_test
{
    class Program
    {
        static void Main(string[] args)
      & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号