Simple C# Noop Statement

2019-03-10 23:48发布

What is a simple Noop statement in C#, that doesn't require implementing a method? (Inline/Lambda methods are OK, though.)

My current use case: I want to occupy the catch-block of a try-catch, so I can step into it while debugging and inspect the exception.
I'm aware I should probably be handling/logging the exception anyway, but that's not the point of this exercise.

标签: c# noop
15条回答
ら.Afraid
2楼-- · 2019-03-11 00:44

Why over-engineer this?

var x = 0;

works just fine :)

查看更多
该账号已被封号
3楼-- · 2019-03-11 00:44

I quite like this, just because it will confuse whoever comes across it:

catch (SomeException e)
{
    lock(e);
} 
查看更多
干净又极端
4楼-- · 2019-03-11 00:46

Reliable solution

try
{
   blablablablaStatemnt();
}
catch(Exception ex)
{
    #IF DEBUG
       Debugger.Break();
    #END IF
}

As simple as this!

Otherwise

breakpoints

can be very usefull;

查看更多
登录 后发表回答