Null && Tenary Operator
This commit is contained in:
parent
1932b125b9
commit
d905100c25
@ -11,5 +11,6 @@ namespace Spg.BasicDemo.Model {
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public long SozNumber { get; set; }
|
||||
public int Id { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
20
Program.cs
20
Program.cs
@ -4,10 +4,13 @@
|
||||
using Spg.BasicDemo.Model;
|
||||
using System.Reflection;
|
||||
|
||||
internal class Program {
|
||||
private static void Main(string[] args) {
|
||||
string s = "Hello, world!";
|
||||
|
||||
Console.WriteLine(s);
|
||||
|
||||
|
||||
Student student = new Student();
|
||||
student.FirstName = "Martin";
|
||||
student.LastName = "Schrutek";
|
||||
@ -25,3 +28,20 @@ foreach (PropertyInfo property in properties) {
|
||||
Console.Out.WriteLine(property.Name);
|
||||
}
|
||||
|
||||
int? e = null;
|
||||
int? f = null;
|
||||
int g = 0;
|
||||
|
||||
Console.WriteLine(e ?? f ?? 5);
|
||||
g = e ?? 0;
|
||||
|
||||
Console.WriteLine(g);
|
||||
|
||||
//string s3 = null;
|
||||
string s3 = "Goodbye, world!";
|
||||
Console.WriteLine($"Length = {s3?.Length ?? 0}");
|
||||
|
||||
bool y = 5 == 5 ? true : false;
|
||||
Console.WriteLine(y);
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
f859f888a51e1a4435b0c78c05e2d5e0bb4e7cbc
|
||||
894e3e29235fe86dbebdadba5ec62bc46a878ace
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user