0
What is the point of adding "?" in front of the parameter variable? Example:
public void somar(int n1, Date data?){
}
OR
public void somar(int n1, Date? data){
}
0
What is the point of adding "?" in front of the parameter variable? Example:
public void somar(int n1, Date data?){
}
OR
public void somar(int n1, Date? data){
}
2
This query allows the field to receive a null value. For example when we declare something like this:
int i;
By default it will receive the value zero, already when we declare:
int? i;
It takes the null value by default.
Cancellable Types
Types allowing null value may represent all values of an underlying type and an additional value null.
Source: https://docs.microsoft.com/pt-br/dotnet/csharp/programming-guide/nullable-types/using-nullable-types
Browser other questions tagged c# oop
You are not signed in. Login or sign up in order to post.
The second example is to say that that parameter is nullable. That is, an int, of course, cannot receive
null
, only one number, with alreadyint?
can get null. Now I’ve never seen the first example.– Felipe Avelar
This is not related to the parameter but to the type.
– Maniero
Thank you, guys.
– Glauco Oliveira