4 Star 1 Fork 1

Dillon/WeixinWinPhone

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SupportClass.cs 2.54 KB
一键复制 编辑 原始数据 按行查看 历史
Dillon 提交于 2014-11-27 23:45 . f
using System;
using System.Collections.Generic;
using System.Text;
public class SupportClass
{
public static byte[] ToByteArray(sbyte[] sbyteArray)
{
byte[] array = null;
if (sbyteArray != null)
{
array = new byte[sbyteArray.Length];
for (int i = 0; i < sbyteArray.Length; i++)
{
array[i] = (byte)sbyteArray[i];
}
}
return array;
}
public static byte[] ToByteArray(string sourceString)
{
return Encoding.get_UTF8().GetBytes(sourceString);
}
public static byte[] ToByteArray(object[] tempObjectArray)
{
byte[] array = null;
if (tempObjectArray != null)
{
array = new byte[tempObjectArray.Length];
for (int i = 0; i < tempObjectArray.Length; i++)
{
array[i] = (byte)tempObjectArray[i];
}
}
return array;
}
public static int URShift(int number, int bits)
{
int result;
if (number >= 0)
{
result = number >> bits;
}
else
{
result = (number >> bits) + (2 << ~bits);
}
return result;
}
public static int URShift(int number, long bits)
{
return SupportClass.URShift(number, (int)bits);
}
public static long URShift(long number, int bits)
{
long result;
if (number >= 0L)
{
result = number >> bits;
}
else
{
result = (number >> bits) + (2L << ~bits);
}
return result;
}
public static long URShift(long number, long bits)
{
return SupportClass.URShift(number, (int)bits);
}
public static long Identity(long literal)
{
return literal;
}
public static ulong Identity(ulong literal)
{
return literal;
}
public static float Identity(float literal)
{
return literal;
}
public static double Identity(double literal)
{
return literal;
}
public static void GetCharsFromString(string sourceString, int sourceStart, int sourceEnd, char[] destinationArray, int destinationStart)
{
int i = sourceStart;
int num = destinationStart;
while (i < sourceEnd)
{
destinationArray[num] = sourceString.get_Chars(i);
i++;
num++;
}
}
public static void SetCapacity(List<object> vector, int newCapacity)
{
if (newCapacity > vector.get_Count())
{
vector.AddRange(new List<object>(newCapacity - vector.get_Count()));
}
else
{
if (newCapacity < vector.get_Count())
{
vector.RemoveRange(newCapacity, vector.get_Count() - newCapacity);
}
}
vector.set_Capacity(newCapacity);
}
public static sbyte[] ToSByteArray(byte[] byteArray)
{
sbyte[] array = null;
if (byteArray != null)
{
array = new sbyte[byteArray.Length];
for (int i = 0; i < byteArray.Length; i++)
{
array[i] = (sbyte)byteArray[i];
}
}
return array;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/dillontools/WeixinWinPhone.git
git@gitee.com:dillontools/WeixinWinPhone.git
dillontools
WeixinWinPhone
WeixinWinPhone
master

搜索帮助