让我们举个例子:
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;
}
}
Run Code Online (Sandbox Code Playgroud)
在这个示例Extentions类中有扩展方法并且我在类中使用它,ABC并且在使用此扩展和其他方法调用的条件下,然后每次我在MakeString()方法中逐步进入时,我们可以跳过它吗?通过使用method attribute?或通过其他方式?
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |