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 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; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
Program.cs
50
Program.cs
@ -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.LastName = "Schrutek";
|
|
||||||
student.Id = 1;
|
|
||||||
|
|
||||||
student.Id.ToString();
|
|
||||||
|
|
||||||
bool isEqual = student.Equals(new Student());
|
|
||||||
|
|
||||||
|
|
||||||
// Reflections
|
Student student = new Student();
|
||||||
PropertyInfo[] properties = student.GetType().GetProperties();
|
student.FirstName = "Martin";
|
||||||
|
student.LastName = "Schrutek";
|
||||||
|
student.Id = 1;
|
||||||
|
|
||||||
foreach (PropertyInfo property in properties) {
|
student.Id.ToString();
|
||||||
|
|
||||||
|
bool isEqual = student.Equals(new Student());
|
||||||
|
|
||||||
|
|
||||||
|
// Reflections
|
||||||
|
PropertyInfo[] properties = student.GetType().GetProperties();
|
||||||
|
|
||||||
|
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.
@ -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