Let's look at the following example:
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);
if(IsValid(obj.MakeString()))
{
}
}
private bool IsValid(string str)
{
return true;
}
}
In this example, a class Extentionsthat has an extension method, and I use it in the class ABC, and when you go into a condition with this extension and another method call, then every time I enter the method MakeString(), can we skip it? Using method attribute? or another way?
source
share