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