【发布时间】:2014-06-22 22:51:39
【问题描述】:
举个例子:
public static class Extensions
{
public static string MakeString(this object obj)
{
if (obj == null) return string.Empty;
return obj.ToString();
}
}
public class ABC
{
public void Method()
{
object obj = default(object);
//Implemention goes here..
// Here every time in step into navigate to MakeString() Method.
if(IsValid(obj.MakeString()))
{
//Operations..
}
}
private bool IsValid(string str)
{
//Check if string is valid or not..
return true;
}
}
在这个例子中,Extentions 类具有扩展方法,并在 ABC 类中使用它,当在此扩展和其他方法调用的条件下步入时,每次我步入 MakeString() 方法时,可以我们跳过它?通过使用method attribute?还是其他方式?
【问题讨论】: