static void Main(string[] args) { Program2 p = new Program2(); Console.WriteLine("hello world" + p.x); Console.ReadLine(); }
static void Main(string[] args) { Program2 program = new Program2(); //Below I am calling the Test() method knowing that Test() will return a value to save from having to initialize another variable. Console.WriteLine("hello world" + program.Test()); }
static void Main(string[] args) { var n = 3000000; var stop = Stopwatch.StartNew(); for (int i = 0; i < n; i++) { var instance = new Program2(i); } Console.WriteLine(stop.ElapsedMilliseconds); stop = Stopwatch.StartNew(); for (int i = 0; i < n; i++) { var instance = Activator.CreateInstance(typeof(Program2), i); } Console.WriteLine(stop.ElapsedMilliseconds); stop = Stopwatch.StartNew(); for (int i = 0; i < n; i++) { var ctor = ActivatorHelper.GetActivator <Program2>(); var instance = ctor(i); } Console.WriteLine(stop.ElapsedMilliseconds); stop = Stopwatch.StartNew(); for (int i = 0; i < n; i++) { var ctor = LazyActivatorHelper.Instance.GetActivator <Program2>(); var instance = ctor(i); } Console.WriteLine(stop.ElapsedMilliseconds); //var key = CacheHelper.GetKey(MethodBase.GetCurrentMethod(), 1, 2, bool.TrueString, false); //var ms = (DateTime.Now.Millisecond); //Console.WriteLine(ms); //CacheFactory.Current.Add(key, ms); //Console.WriteLine("aaa"); //Console.WriteLine(CacheFactory.Current.Get<int>(key)); //Console.WriteLine(typeof(Program).FullName); ////Log.ThreadVariablesContext.Set("url", "http://abc.com"); //Log.Debug("b"); //Log.Warn("Asdfasfasf"); //Log.Error("Asdfasfasf"); //Log.Info("Asdfasfasf"); //Log.Fatal("Asdfasfasf"); }
public static void Main(string[] args) { Program2 Pr = new Program2(); Pr.Print(); // Second Way : Through the parent class reference variable, -- // -- we can create the instance of the derived class, and call the method. Customer Cr = new Program2(); Cr.Print(); Console.ReadKey(); }
public static void getInput() { Console.WriteLine("hello world"); Console.Write("Length: "); String input = Console.ReadLine(); //Convert.ToDouble(input); double length = Double.Parse(input); Console.Write("Width: "); input = Console.ReadLine(); double width = Double.Parse(input); Program2 p = new Program2(); int w = (int)State.Complete; p.setDimens(length, width); Cube c = new Cube(); c.setDimens(3, 3); c.setHeight(3); c.setVolume(); Console.WriteLine("Cube Volume = {0}", c.getVolume()); Console.WriteLine("Length = {0}\nWidth = {1}\nArea = {2}\nVar = {3}", p.getLength(), p.getWidth(), p.getArea(), p.getVar()); dynamic z = p.getVar(); if (z is double) { p1(); } else { p2(); } int row = (int)z; if (z is double) { p1(); } else { p2(); } Console.WriteLine("Var = {0}", z); Books Book1 = new Books(); Book1.setValues("1984", "George Orwell", 345, 109091561); Book1.display(); Cube c2 = new Cube(); c2.setDimens(3, 3); c2.setHeight(3); c2.setVolume(); Shape c3 = new Cube(); c3 = c2 + c; c3.setVolume(); Console.WriteLine("C3 = {0}, {1}, {2}, {3}", c3.getWidth(), c3.getLength(), c3.getVolume(), c3.getHeight()); Console.ReadKey(); //recursivePrint("Hello", row); //for(int i = row; i > 0; i--) //{ // Console.WriteLine(Program2.arr[i-1]); //} primes2(1000000); //one billion tried -> 1million }