Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similar to Pass in Python for C#

Tags:

python

c#

People also ask

What is equivalent of pass in C?

def f(): pass. becomes void f() {} and class C: pass. becomes class C {};

Is there a pass command in C?

If you want to pass command line arguments then you will have to define the main() function with two arguments. The first argument defines the number of command line arguments and the second argument is the list of command line arguments.

What can I use instead of pass in Python?

With Python >= 3.0, you should use ... (Ellipsis) instead of pass to indicate "finish later" blocks.

Does C++ have pass?

In C++ we can pass class's objects as arguments and also return them from a function the same way we pass and return other variables.


Use empty braces.

int a = 5;
if (a == 5) {}
else {
  Console.Write("Hello World");
}

Why not just say:

if (a != 5) 
{
   Console.Write("Hello World");
}

In case you don't want to use empty block, use

;

so the code should look like

int a = 5;
if (a == 5)
  ;
else 
{
  Console.Write("Hello World");
}

although, code readability still suffer.


Empty block:

{}

Is pass used in the context of a loop? If so, use the continue statement:

for (var i = 0; i < 10; ++i)
{
    if (i == 5)
    {
        continue;
    }

    Console.WriteLine("Hello World");
}

Either use an empty block as suggested in other answers, or reverse the condition:

if (a != 5)
{
    Console.WriteLine("Hello world");
}

or more mechanically:

if (!(a == 5))
{
    Console.WriteLine("Hello world");
}