diff options
| author | Max Yankov <golergka@gmail.com> | 2013-08-17 15:57:52 +0200 | 
|---|---|---|
| committer | Max Yankov <golergka@gmail.com> | 2013-08-17 15:57:52 +0200 | 
| commit | 2173dd419a1daa06efee295e3fe2cdbc40224433 (patch) | |
| tree | 079d7ab8511c5d8ae8a42e0562cc9b658ca8813a /csharp.html.markdown | |
| parent | 9a9b5a31e079c635fe4c5afc1127f88fbad091f3 (diff) | |
Accessing nullable's value in C#
Diffstat (limited to 'csharp.html.markdown')
| -rw-r--r-- | csharp.html.markdown | 4 | 
1 files changed, 4 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown index c254b5a9..c9df6db9 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -144,6 +144,10 @@ namespace Learning              int? nullable = null;              Console.WriteLine("Nullable variable: " + nullable); +            // In order to use nullable's value, you have to use Value property or to explicitly cast it +            string? nullableString = "not null"; +            Console.WriteLine("Nullable value is: " + nullableString.Value + " or: " + (string) nullableString ); +              // ?? is syntactic sugar for specifying default value              // in case variable is null              int notNullable = nullable ?? 0;  | 
