Simple C# Noop Statement

后端 未结 15 734
面向向阳花
面向向阳花 2021-02-01 01:14

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 c

15条回答
  •  粉色の甜心
    2021-02-01 01:48

    The standard empty statement/noop operation in c# is

    ;
    

    as in:

    if (true)
        ;
    

    (relevant documentation)

    this specifically addresses your use case (just place a break-point on the ; line, or otherwise step to it), is minimal, and is directly supported by the environment just for this purpose (so you even if you're doing complex things, like looking at the compiled source, you won't have any additional noise/etc.. to worry about from the compiler/optimizer/etc...) - and has the additional benefit of putting up a warning, as a reminder to clean it out of your code when you're done debugging/push to production

提交回复
热议问题