I would like to have something like tkis “int?” but for string. You know if I will not give data to parameter I will not got error. I need some idea to this problem.
Example(4);
public void Example(int, string?){}
For all of you I give points. Thanks for help. Topic [closed] 🙂
This isn’t available as
stringis already a reference type, so is already nullable. The?suffix is syntactic sugar forNullable<T>, soint?is equivalent toNullable<int>… andNullable<T>has a constraint ofwhere T : struct, i.e.Thas to be a non-nullable value type… which excludesstring.In other words, you can just write
Note that this is different from making it an optional parameter. Passing in a
nullvalue is still passing in a value. If you want to make it an optional parameter you can do that too: