Null && Tenary Operator

This commit is contained in:
Andre Fuhry 2022-09-26 17:09:14 +02:00
parent 1932b125b9
commit d905100c25
9 changed files with 35 additions and 14 deletions

View File

@ -11,5 +11,6 @@ namespace Spg.BasicDemo.Model {
public string FirstName { get; set; } public string FirstName { get; set; }
public string LastName { get; set; } public string LastName { get; set; }
public long SozNumber { get; set; } public long SozNumber { get; set; }
public int Id { get; internal set; }
} }
} }

View File

@ -4,10 +4,13 @@
using Spg.BasicDemo.Model; using Spg.BasicDemo.Model;
using System.Reflection; using System.Reflection;
internal class Program {
private static void Main(string[] args) {
string s = "Hello, world!"; string s = "Hello, world!";
Console.WriteLine(s); Console.WriteLine(s);
Student student = new Student(); Student student = new Student();
student.FirstName = "Martin"; student.FirstName = "Martin";
student.LastName = "Schrutek"; student.LastName = "Schrutek";
@ -25,3 +28,20 @@ foreach (PropertyInfo property in properties) {
Console.Out.WriteLine(property.Name); 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.

View File

@ -1 +1 @@
f859f888a51e1a4435b0c78c05e2d5e0bb4e7cbc 894e3e29235fe86dbebdadba5ec62bc46a878ace

Binary file not shown.

Binary file not shown.