Exemplo n.º 1
0
        private static void ArrayExample()
        {
            var customers = new Customer[5];
            Random r = new Random();
            for (int i = 0; i < 5; i++)
            {
                customers[i] = new Customer();
                customers[i].Age = r.Next();

            }
            foreach (Customer cst in customers)
            {
                Console.WriteLine(cst.Age + "\t");
            }
        }
Exemplo n.º 2
0
        private static void BasicObjectOrientation()
        {
            Customer cust = new Customer();
            cust.Setter("rahim");
            Console.WriteLine(cust.Getter());

            Customer cust2 = new Customer()
            {
                Age = 23
            };
            Console.WriteLine(cust2.Age);

            Customer cust3 = new Customer("salma", 12);

            Dealer dlr = new Dealer("akib", 23, "00-aaB");
            Console.WriteLine(dlr.Age + "\t" + dlr.Name + "\t" + dlr.Dealer_Code);
            dlr.Display();
        }
Exemplo n.º 3
0
        private static void LinqExapmle()
        {
            int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };
            var mylinqquery =
                from num in numbers
                where (num % 2) == 0
                select num;
            foreach (int num in mylinqquery)
            {
                Console.Write("{0}\t", num);
            }
            Customer cust;
            List<Customer> custmoberlist = new List<Customer>();
            for (int i = 0; i < 10; i++)
            {
                cust = new Customer("name-" + i, (2 * i) + i);
                custmoberlist.Add(cust);
            }

            IEnumerable<Customer> customerQuery =
                    from custs in custmoberlist
                    where custs.Age > 10
                    select custs;

            foreach (Customer custs in customerQuery)
            {
                Console.WriteLine(custs.Name + "\t " + custs.Age);
            }
        }
Exemplo n.º 4
0
        private static void ListExample()
        {
            List<int> mylist = new List<int>();
             	        List<int> customerlist = new List<int>();
            mylist.Add(5);
            mylist.Add(3);
            mylist.RemoveAt(0);
            foreach (int lst in mylist)
            {
                 Console.Write(lst + "\t");
            }

            List<Customer> customerlist2 = new List<Customer>();
            for (int i = 0; i < 5; i++)
            {
             Customer cust = new Customer("item-" + i, (i * i + 20));
             customerlist2.Add(cust);
            }
            foreach (Customer cust in customerlist2)
            {
               Console.WriteLine("Name: {0} \t Age: {1}", cust.Name, cust.Age);
            }
        }