Spg.BasicDemo/Program.cs

47 lines
1.1 KiB
C#
Raw Permalink Normal View History

2022-09-26 16:37:42 +02:00
// See https://aka.ms/new-console-template for more information
//Console.WriteLine("Hello, World!");
using Spg.BasicDemo.Model;
using System.Reflection;
2022-09-26 17:09:14 +02:00
internal class Program {
private static void Main(string[] args) {
string s = "Hello, world!";
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
Console.WriteLine(s);
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
Student student = new Student();
student.FirstName = "Martin";
student.LastName = "Schrutek";
student.Id = 1;
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
student.Id.ToString();
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
bool isEqual = student.Equals(new Student());
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
// Reflections
PropertyInfo[] properties = student.GetType().GetProperties();
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
foreach (PropertyInfo property in properties) {
Console.Out.WriteLine(property.Name);
}
2022-09-26 16:37:42 +02:00
2022-09-26 17:09:14 +02:00
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);
}
}