Example #1
0
 public clsShallow CreateShallowCopy(clsShallow inputcls)
 {
     return((clsShallow)inputcls.MemberwiseClone());
 }
Example #2
0
        static void Main(string[] args)
        {
            var clsShallow1 = new clsShallow(20);

            clsShallow1.printMony();
            var abcd = new List <M1>();

            abcd.Add(new test.M1()
            {
                Id = 1, Name = "test 1"
            });
            //abcd.Add(new test.M1() { Id = 2, Name = "test 2" });
            var x112 = abcd.First();
            var x222 = abcd.Single();
            int n, sum = 0, m;

            Console.Write("Enter a number: ");
            n = int.Parse(Console.ReadLine());
            while (n > 0)
            {
                m   = n % 10;
                sum = sum + m;
                n   = n / 10;
            }
            Console.Write("Sum is= " + sum);



            // ############################ Deep Copy ############################
            // Creates an instance of clsDeep and assign values to its fields.
            clsDeep objdeep = new clsDeep();

            objdeep.Age          = 25;
            objdeep.EmployeeName = "Ahmed Eid";

            // add the ref value
            clsRefSalary clsref = new clsRefSalary(1000);

            objdeep.EmpSalary = clsref;

            // Performs a shallow copy of m1 and assign it to m2.
            clsDeep m2 = objdeep.CreateDeepCopy();

            // then modify the clsref salary value to be 2000
            clsref.Salary = 2000;

            // so the m1 object salary value become 2000
            int EmpSalary = objdeep.EmpSalary.Salary;


            // ############################ Shallow Copy ############################
            clsShallow objshallow = new clsShallow();

            objshallow.Age          = 25;
            objshallow.EmployeeName = "Ahmed Eid";

            // add the ref value to the objshallow
            clsRefSalary clsref1 = new clsRefSalary(1000);

            objshallow.EmpSalary = clsref1;

            // Performs a shallow copy of m1 and assign it to m2.
            clsShallow m21 = objshallow.CreateShallowCopy(objshallow);

            // then modify the clsref salary value to be 2000
            clsref.Salary = 2000;

            // so the m1 object salary value become 2000
            int EmpSalary1 = objshallow.EmpSalary.Salary;



            var c1 = new Customer();

            c1.MyProperty = 2;
            var customer2 = c1.shallowCopy();
            var customer3 = c1.deepCopy();

            c1.MyProperty = 5;



            List <Employee1> employeeList = new List <Employee1>();

            employeeList.Add(new NewEmployee());
            foreach (Employee1 e in employeeList)
            {
                e.GetProjectDetails(1245);
            }



            var silverCustomer = new SilverCustomer();

            Console.WriteLine(silverCustomer.getDiscount(10.10));
            var         var2    = 5;
            var         var3    = 6;
            var         var1    = var2 = var3;
            IList <int> strList = new List <int>()
            {
                6, 2, 9, 1
            };
            //var tt = strList.OrderBy().Skip(1).Take(1);
            b b1 = new b();

            b1.print();
            int x1 = 10;
            int y  = 20;

            Test(out x1, out y);
            object name = "sandeep";

            char[] values = { 's', 'a', 'n', 'd', 'e', 'e', 'p' };
            object myName = new string(values);

            Console.WriteLine("== operator result is {0}", name == myName);
            Console.WriteLine("Equals method result is {0}", myName.Equals(name));
            Console.ReadKey();

            myDelegate obj5 = new myDelegate(addOne);

            Console.WriteLine(obj5("test 2"));


            myDelegate obj6 = delegate(string b) { return(b); };

            Console.WriteLine(obj6("t"));

            myDelegate obj7 = (x) => { return(x); };

            Console.WriteLine(obj7("t2"));



            while (true)
            {
                try
                {
                    continue;
                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                }
            }
            ExtractProcess  eETL = new ExtractProcess();
            TransferProcess tETL = new TransferProcess();
            LoadProcess     lETL = new LoadProcess();

            eETL.SetNextProcess(tETL);
            tETL.SetNextProcess(lETL);

            eETL.Process();

            ETL etl = new StructuredDataETL();

            etl.Execute();


            Singletone obj3 = Singletone.GetInstance;
            Singletone obj4 = Singletone.GetInstance;

            Employee emp = new Employee();

            var container = new UnityContainer();

            container.RegisterType <IDI, DI>();

            MyClass obj  = new MyClass(1, "test");
            MyClass obj1 = new MyClass(obj);

            Console.WriteLine("{0} , {1} ", obj1.id, obj1.name);
            Console.ReadLine();
        }