private static void Main()
{
Console.WriteLine(GetRandomInteger());
Console.ReadLine();
}
[DebuggerHidden]
private static int GetRandomInteger()
{
Func<int> random = () => 4;
return GetRandomInteger(random);
}
[DebuggerHidden]
private static int GetRandomInteger(Func<int> random)
{
return random();
}
Using the code above, is there a way to prevent the Func<int> random = () => 4;
line from getting stepped into when debugging?
Well you could use a private function with the [DebuggerHidden]
attribute instead of a labmda, and set the Func<int>
delegate to the private function.
[DebuggerHidden]
can be used on a property, and this property appears to behave as you would like:
[DebuggerHidden]
private static Func<int> random
{
get { return () => 4; }
}
It is a workaround, like the other answer; however, it keeps the lambda and may be closer to the original intent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With