利用C#,不調用系統提供的庫函數的情況下,編寫出幾個有關字符串的操作方法:
namespace StringOperate
{
class StrOperate
{
//return a copy of the src
public static char[] StrCopy(char[] src)
{
char[] data = null;
if (ReferenceEquals(src, null))
{
return data;
}
int length = src.Length;
data = new char[length];
for (int i = 0; i < length; i++)
{
data[i] = src[i];
}
return data;
}
//copy the src to the des and return the des
public static char[] StrCopy(out char[] des, char[] src)
{
if (ReferenceEquals(src, null))
{
des = null;
return des;
}