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,24 +4,44 @@
using Spg.BasicDemo.Model; using Spg.BasicDemo.Model;
using System.Reflection; using System.Reflection;
string s = "Hello, world!"; internal class Program {
private static void Main(string[] args) {
string s = "Hello, world!";
Console.WriteLine(s); Console.WriteLine(s);
Student student = new Student();
student.FirstName = "Martin"; Student student = new Student();
student.LastName = "Schrutek"; student.FirstName = "Martin";
student.Id = 1; student.LastName = "Schrutek";
student.Id = 1;
student.Id.ToString(); student.Id.ToString();
bool isEqual = student.Equals(new Student()); bool isEqual = student.Equals(new Student());
// Reflections // Reflections
PropertyInfo[] properties = student.GetType().GetProperties(); PropertyInfo[] properties = student.GetType().GetProperties();
foreach (PropertyInfo property in properties) { 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.