What is a bool? isActive = false in C #?

As the question shows, what does the following code mean?

public void blabla (bool? isActive = false) { } 
+4
source share
5 answers

Well, this is the void method (returns nothing), taking the optional parameter ( isActive = false ) with a boolean value of zero ( bool? ), Where the default value is false.

This is a public method, meaning that code that has access to the class / structure containing this method can see this method. public is called an access modifier.

Access Modifiers:

http://msdn.microsoft.com/en-us/library/wxh6fsc7(v=VS.100).aspx

Extra options:

http://msdn.microsoft.com/en-us/library/dd264739.aspx

Impossible types:

http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=VS.100).aspx

As for this value, it depends on whether he is responsible for maintaining the aircraft in the air or not: -P

+8
source

bool? indicates that it is a null type that supports true , false or null . = false indicates that if no value is specified, this is false , which is the default value.

+6
source

its optional parameter with a null boolean value with a default value of false

+2
source

This makes bool a type with a null value:

See: http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx

+1
source

This means that it creates a new method, and a parameter with the value DEFAULT means that you can call it in two ways:
blabla(true); or blabla(false) or blabla(null)
or:
blabla() and this will give the default value FALSE.

+1
source

All Articles