static void Main(string[] args) { Animal a = new Cat(); Console.WriteLine(a.ToString()); a.gaugau(); a.sound(); a.Eat(); Cat b = new Cat(); Console.WriteLine(b.ToString()); b.sound(); b.Eat(); }
private static async Task Main(string[] args) { Func <int, int, bool> fa = Compare.Invoke; myTimer t = new myTimer(); await Scrape.Download(); WriteLine(1__2333_4_5); WriteLine(6.023E23F); WriteLine(float.MaxValue); WriteLine(double.MaxValue); WriteLine(decimal.MaxValue); WriteLine(0x_2002a); WriteLine(0b_00101010101); WriteLine($"0x{42:x8}"); WriteLine(Convert.ToString(42, 2)); WriteLine(); const double num = 1.618033988749895; double res; string text; text = $"{num}"; res = double.Parse(text); WriteLine($"{res == num}"); text = $"{num:R}"; res = double.Parse(text); WriteLine($"{res == num}"); WriteLine($"{num:R}\t{res}"); WriteLine(string.Compare("SBAA", "sbab", StringComparison.OrdinalIgnoreCase)); Write('\u003a'); WriteLine('\u0029'); WriteLine($@"begin /\ / \{text} / \ /______\ end "); var price = 9899.66; WriteLine($"{{{price,20:C2} }}"); unchecked { var maxInt = int.MaxValue; WriteLine(++maxInt); } var(country, capital, gdp) = ("Malawi", "Lilongwe", 226.50); var countryInfo = (country, capital, gdp); var cInfo = ("Malawi", Capital : "Lilongwe", 226.50); WriteLine($"{countryInfo.country} {cInfo.Item2} {gdp}"); var c = new[] { new[] { 1, 2, 3 }, new[] { 1, 4, 5, 9 } }; var cells = new[, ] { { 1, 2, 3 }, { 1, 4, 9 } }; c[1][0] = 2; var d = c.Clone(); //Array.Resize(ref cells, 9); WriteLine(cells.GetLength(0)); WriteLine(cells.Rank); WriteLine(new string(text.Reverse().ToArray())); char[] charArray = text.ToCharArray(); Array.Reverse(charArray); string news = new string(charArray); var n = '3' + '5'; WriteLine((char)n); float f = -6f; WriteLine(f / 0); WriteLine(3.4e38f * 2f); if (n > 1 || n < 5) { WriteLine("ok"); } var x1 = -7; x1 >>= 2; WriteLine(x1); byte and = 12, or = 12, xor = 12; and &= 7; or |= 7; xor ^= 7; WriteLine($"{and}\t{or}\t{xor}"); WriteLine(Convert.ToString(9989, 2)); int a = ~-1; goto myLabel; a++; myLabel : WriteLine(Convert.ToString(a, 2)); var am = new Cat(20) { StarPoint = 100 }; TestReference(am); WriteLine($"SP after test: {am.StarPoint}"); var am2 = new Cat(150, 99) { StarPoint = 100 }; var(age, _, starPoint, _) = am2; var(j, k, l) = (3, "", '2'); am2.Deconstruct(out var age2, out _, out var sp, out _); WriteLine($"am2 SP={am2.StarPoint} age={Cat.Age}"); WriteLine($"am2 SP={starPoint} age={age}"); am.Eat(); Animal.Sleep(); am.Run(); WriteLine($"Sp={am.StarPoint}"); WriteLine(am.Num); WriteLine(Animal.Age); WriteLine("---------------------------------"); Cat ct = (Cat)am; WriteLine(ct.Num); WriteLine(Cat.Age); WriteLine(ct.Name); ct.Eat(); Cat.Sleep(); ct.Run(); ct.CatchMouse(); var an = new Animal(); WriteLine(an.Num); var sortArr = new[] { 1, 8, 2, 0, -3, 12, 6 }; Array.Sort(sortArr); Array.Resize(ref sortArr, 10); WriteLine(sortArr.Length); int?a1 = sortArr?[1]; foreach (var i in sortArr) { Write(i + " "); } WriteLine(); var o = new object(); if (o is string str && str.Length > 2) { int.TryParse(str, out _); }