2
難道這不是更好嗎? SQL Server 2005的.NET 2.0的兼容性:代碼審查:CLR RegexSubstring
public static SqlString RegexSubstring(SqlString regexpattern,
SqlString sourcetext,
SqlInt32 start_position)
{
SqlString result = null;
if (!regexpattern.IsNull && !sourcetext.IsNull && !start_position.IsNull)
{
int start_location = (int)start_position >= 0 ? (int)start_position : 0;
Regex RegexInstance = new Regex(regexpattern.ToString());
result = new SqlString(RegexInstance.Match(sourcetext.ToString(),
start_location).Value);
}
return result;
}
這是我在寫CLR函數/等爲SQL Server的第一次嘗試 - 是絕對有必要使用的SqlString /等數據類型的參數?
欣賞更新 - 不知道是什麼我站從抽象所以我不調用toString()方法中獲得。 – 2010-05-12 21:30:40
啊,就像我說過它只是一種風格的東西。有時對於單元測試隔離,人們喜歡儘可能少地依賴。 – 2010-05-12 22:05:38
不用擔心,以爲你指的是多重返回與單數返回語句模式/反模式。 – 2010-05-12 22:15:12