static void Main(string[] args) { System.Int32 i = 1; string t = i.ToString(); Console.WriteLine(int.MinValue); Console.WriteLine(int.MaxValue); int ii; ii = 100; System.Boolean b = false; bool bb = false; // kommatal double d = 0; Console.WriteLine(d); System.Double dd; d = 343454.983593879379854; Console.WriteLine(d.ToString("N2")); System.DateTime da; da = System.DateTime.Now; Console.WriteLine(da.ToString("dddd")); // Dato beregninger System.DateTime d1 = System.DateTime.Now; System.DateTime d2 = new DateTime(2018, 12, 24); System.TimeSpan ts = d2.Subtract(d1); Console.WriteLine(ts.TotalDays.ToString()); System.DateTime d3 = System.DateTime.Now.AddMonths(1); System.TimeSpan ts2 = new TimeSpan(15, 00, 00); System.TimeSpan ts3 = new TimeSpan(17, 00, 00); ts2 = ts2.Add(new TimeSpan(0, 20, 10)); Console.WriteLine(ts2 > ts3); const int antalMåneder = 12; //antalMåneder = 11; const double momsPct = 0.25; // xlm config, settings int q = 1; q++; q += 2; q *= 2; //q -= 8; q = q - 8; if (DateTime.Now.Millisecond % 2 == 0) { // lige } else { // ulige } // Hund d = new Hund(); int a = 500000000; //checked //{ // short z = (short)a; //} // short z = System.Convert.ToInt16(a); // short z2 = System.Convert.ToInt16("7575757"); var x = "888"; var navn = "mikkel"; int[] tal = { 4, 2, 4, 10, 5, 7, 10, 6, 2 }; var tal2 = tal.Where(s => s < 10).OrderBy(s => s).GroupBy(s => s); int antalm = 12; string personNavn = "Mikkel"; //int personKøn = 1; // 1 = mand, 0 = kvinde PersonKøn personKøn = PersonKøn.Kvinde; Console.WriteLine((int)personKøn); KortFarve k = KortFarve.Klør; switch (k) { case KortFarve.Spar: break; case KortFarve.Hjerter: break; case KortFarve.Ruder: break; case KortFarve.Klør: break; default: break; } DayOfWeek d6 = DayOfWeek.Monday; switch (d6) { case DayOfWeek.Sunday: break; case DayOfWeek.Monday: break; case DayOfWeek.Tuesday: break; case DayOfWeek.Wednesday: break; case DayOfWeek.Thursday: break; case DayOfWeek.Friday: break; case DayOfWeek.Saturday: break; default: break; } int Person1Alder = 20; string Person1Navn = "a"; int Person2Alder = 50; string Person2Navn = "b"; //Person p1; ////p1.Alder++; //p1.Alder = 10; //p1.Navn = "a"; // initialiseret til default Person p2 = new Person(); p2.Alder++; p2.Alder = 30; p2.Navn = "b"; //Console.WriteLine(p1.Equals(p2)); // ****************************************** // Summering // ****************************************** // int // double // bool, datetime, timespan // enum // struct int p = 1; int l = 2; p = l; l = 5; Person a1 = new Person(); a1.Alder = 10; a1.Navn = "a"; Person a2 = new Person(); a2.Alder = 20; a2.Navn = "a"; a1 = a2; a1.Navn = "b"; //Console.WriteLine(a1.Equals(a2)); }
static void Main(string[] args) { System.Int32 i; i = 0; // i = null; int x; string tmp = i.ToString(); long t = 10; bool g = true; System.Boolean h = false; double k = 1986700.75757; Console.WriteLine(k.ToString()); Console.WriteLine(k.ToString("N3")); Console.WriteLine(k); int e1; double e2; bool e3; DateTime d = DateTime.MinValue; DateTime d2 = DateTime.Now; DateTime d3 = new DateTime(2018, 12, 24); Console.WriteLine(d3); Console.WriteLine(d3.ToString("yyyy dddd")); TimeSpan ts1 = d3.Subtract(d2); Console.WriteLine(ts1.TotalMinutes); TimeSpan ts2 = new TimeSpan(14, 00, 00); Console.WriteLine(ts2); int y = 100; int Y = 200; const int antalMåneder = 12; // antalMåneder = 10; // System.Configuration.ConfigurationManager. double momsPct = 0.25; // App settings (kræver setting i egenskaber til project) Variabler.Properties.Settings.Default.Moms = 0.1; Variabler.Properties.Settings.Default.Save(); i++; i--; i += 10; i *= 20; if (i % 2 == 0) { // lige tal } else { // ulige tal } i = 500000000; //short j = (short)i; //checked //{ // short j = (short)i; //} //short j = Convert.ToInt16(i); DateTime d5 = Convert.ToDateTime("2017-5-15"); var q = 1.7; var u = 34; // int[] ar = { 4, 2, 1, 4, 5 }; // var res2 = ar.Where(r => r < 10).OrderBy(r => r).GroupBy(r => r); var nyv = 10; int nyv1 = 10; string navn1 = "Mikkel"; int køn1 = 1; // 1 = mand int alder1 = 10; string navn2 = "Lene"; int køn2 = 0; // 0 = kvinde int alder2 = 20; string navn3 = "Mathias"; Køn køn3 = Køn.Mand; int alder3 = 80; Person p4 = new Person(); p4.Navn = "Anette"; p4.Køn = Køn.Kvinde; p4.Alder = 54; Person p5 = p4; Console.WriteLine(Convert.ToUInt32(køn3)); DayOfWeek dag = DayOfWeek.Sunday; if (dag == DayOfWeek.Sunday) { } switch (dag) { case DayOfWeek.Sunday: break; case DayOfWeek.Monday: break; case DayOfWeek.Tuesday: case DayOfWeek.Wednesday: break; case DayOfWeek.Thursday: break; case DayOfWeek.Friday: break; case DayOfWeek.Saturday: break; default: break; } KortFarve kort = KortFarve.Ruder; Person p6 = new Person(); // initialiser til default værdier p6.Alder++; KortFarve tt; }