2009/04/02

c# Replace字串

public static string Replease(string originalStr, string repleasStr, string newStr)
{
int pos = originalStr.IndexOf(repleasStr);
int len = repleasStr.Length;
if (pos != -1)
{
string strLeft = originalStr.Substring(0, pos);
string strRight = originalStr.Substring(pos + len);
return strLeft + newStr + strRight;

}
else
return originalStr;

}

c# 慣用的命名法


識別字種類習慣的命名原則範例
常數使用英文大寫字母和底線"_"符號MAX_SIZE, PI
變數使用英文小寫字母開頭,如果是2個英文字組成,第2個之後的英文字以大寫開頭size, userName
函數使用英文小寫字母開頭,甘果是2個英文組成,其化英文字使用大寫開頭pressButton, scrollScreen