-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
83 lines (61 loc) · 2.38 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;
namespace Nullables
{
struct Book
{
int id;
string title;
string genre;
}
class Shapes
{
int id;
static void function()
{
}
}
class Program
{
static void Main(string[] args)
{
int? @int = null;
// int @int = null; // Error, harus ada operator nullable (<type>? <variable>)
short? @short = null;
// short @short = null; // Error, harus ada operator nullable (<type>? <variable>)
long? @long = null;
// long @long = null; // Error, harus ada operator nullable (<type>? <variable>)
float? @float = null;
// long @long = null; // Error, harus ada operator nullable (<type>? <variable>)
double? @double = null;
// long @long = null; // Error, harus ada operator nullable (<type>? <variable>)
decimal? @decimal = null;
// decimal @decimal = null; // Error, harus ada operator nullable (<type>? <variable>)
bool? @bool = null;
// bool @bool = null; // Error, harus ada operator nullable (<type>? <variable>)
char? @char = null;
// char @char = null; // Error, harus ada operator nullable (<type>? <variable>)
byte? @byte = null;
// byte? @byte = null; // Error, harus ada operator nullable (<type>? <variable>)
Book? book = null;
// Book book = null; // Error, harus ada operator nullable (<type>? <variable>)
Shapes shape = null;
string @string = null; // Tidak Error,
// Using null coalescing operator
string str01 = null, str02 = null, str03 = null, str04 = "Have String", str05 = "Second string" ;
string strFinal = str01 ?? str02 ?? str03 ?? str04 ?? str05;
Console.WriteLine("String yang dicetak : " + strFinal);
int? var01 = null;
int? var02 = null;
int? var03 = null;
int? var04 = null;
int? var05 = 100;
int? var06 = 500;
int? strF = var01 ?? var02 ?? var03 ?? var04 ?? var05 ?? var06;
Console.WriteLine("String yang dicetak : {0}", strF);
Console.ReadKey();
}
}
}