Пример #1
0
        static void Main(string[] args)
        {
            var cart = new shoppingcart();

            for (int i = 0; i < cart.items.Length; i++)
            {
                Console.WriteLine(cart.items[i].Getvat());
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            /*
             * var missile = new Missile();
             * // missile.damagepower = 100;   //we can comment this as if we have used costructor in missile class
             * missile.fire();
             * var gun = new Machinegun();
             * gun.fire();
             */

            var cart = new shoppingcart();

            for (int i = 0; i < cart.items.Length; i++)
            {
                Console.WriteLine(cart.items[i].Getvat());
            }

            /*   int x; //explicit variable
             * double y; //explicite variable
             *
             * var z = 5; //Implicit variable ( we should use var )
             * var a = 5.6;//Implicite variable bydefault double
             * var e = 4.7f;// float
             * var u = 3.7m;
             * var b = true; //Implicit variable
             * var c = DateTime.Now; // it shows current date along with time ( implicit variable)
             * //Console.WriteLine("Hello World!");
             *
             * var q= x>y ? x:y // trinary operator, conditional check
             *
             * string s= "hello";
             * string ss= s?? "Empty"; // part of trinary operator
             *
             * var t= x==null ? "empty" : t; //trinary operator, specialy aaplicable for null checking
             *
             * // anonymious type : use to create an object . we can not make a copy of it. it has seperate name with same or different values.
             * var person = new
             * {
             *     firstName = "Ifrat",
             *     lastName = "Jahan",
             *     Age = 25
             * };
             * var person2 = new
             * {
             *     firstName = "Juthi",
             *     lastName = "sarker"
             * };
             *
             * Console.WriteLine(person.Age);
             * Console.WriteLine(person2.firstName);
             * // dynamic type: here we can assign any value , always get the updated value in cw . we can make many copy with a same keyword dynamic something variable...and assign different values.
             * dynamic something = "nishu";
             * something = 10;
             * something = true;
             * something = 3.3;
             * something = new
             * {
             *     name = "mesbha",
             *     age = 32
             * };
             * Console.WriteLine(something);
             *
             * //  use of var is very important because if we change any class name we should not change it in the variable section where we want to call the getcar function ..so using var is a good practice
             * // Car c = new Car();
             * // var d = new Car();
             *
             * Car c = GetCar();
             * var d = GetCar();
             * }
             *
             * public static Car GetCar()
             * {
             * return new Car;
             * }
             *
             *
             * }
             *
             * class Car
             * {
             * public int fuel;
             * }
             */
        }