我想做点什么
string s = "Hello";
s.Clear();
Run Code Online (Sandbox Code Playgroud)
我创建了这样的扩展方法:
public static void Clear(this string s)
{
s = string.Empty;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我看到价值时,它不会改变:
我不能使用ref或out,因为这些不能与关键字this一起使用 .有任何想法吗?