Reputation: 7684
As the question depicts, what does the following code mean?
public void blabla (bool? isActive = false) {
}
Upvotes: 4
Views: 2886
Reputation: 64487
Well, it is a void method (returns nothing) taking an optional parameter (isActive = false
) of a nullable boolean (bool?
), where the default value is false.
It is a public method, meaning that code that has access to the class / struct that contains this method can see the method. The public
is called an access modifier.
Access modifiers:
http://msdn.microsoft.com/en-us/library/wxh6fsc7(v=VS.100).aspx
Optional parameters:
http://msdn.microsoft.com/en-us/library/dd264739.aspx
Nullable types:
http://msdn.microsoft.com/en-us/library/1t3y8s4s(v=VS.100).aspx
As for it's significance, that depends if it's responsible for keeping planes in the air or not :-P
Upvotes: 8
Reputation: 5550
It means it makes a new method, and a parameter with a DEFAULT value - that means you can call it by two ways:
blabla(true);
or blabla(false)
or blabla(null)
or:
blabla()
and it'll give the default value of FALSE.
Upvotes: 1
Reputation: 6305
It makes bool a nullable type:
See: http://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx
Upvotes: 1
Reputation: 4108
its an optional parameter of nullable boolean with a default value of false
Upvotes: 2
Reputation: 44706
bool?
indicates that it's a nullable type, supporting true
, false
or null
. = false
indicates that if a value isn't supplied, it is false
which is the default value.
Upvotes: 6