Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine(ABC.constant);           
            ABC obj1 = new ABC();
            ABC obj2 = new ABC();
            
            Console.WriteLine(obj1);
            Console.WriteLine(obj2);
            obj1.Func(obj2);
            Console.WriteLine(obj1);
            Console.WriteLine(obj2);
            Hashtable ht = new Hashtable();
            HKey k = null;
            try
            {
                ht.Add(k, "test");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            string str1 = "mystr";
            string str2 = "mystr";

            Console.WriteLine(object.ReferenceEquals(str1, str2));
            Console.WriteLine(object.Equals(str1, str2));
            try
            {
                DelegateTest.Test();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            List<Person> persons = new List<Person>()
            {
                new Person("Abhay","Deshmukh"),
                new Person("Pralay","Patoria"),
                new Person("Shubhi","Patoria")
            };

            //var res = from person in persons orderby person.FirstName descending;
            var res1 = from person in persons
                       where person.FirstName == "Pralay"
                       select new { Name = person.FirstName, Surname = "Patoria" };
            foreach(var p in res1)
            {
                Console.WriteLine(string.Format("{0} {1}",p.Name,p.Surname));
            }

            //List<Person> matches = 
            //persons
            //    .FindAll(person => person.LastName == "Patoria")
            //    .ForEach(Console.WriteLine);

            persons
                .Select(person => person.LastName.Equals("Patoria")).ToList()
                .ForEach(Console.WriteLine);

            ReadonlyProperty.Test();
            TestStringWithDictionary();
            MyGCCollectClass.Test();
            structure st1 = new structure { x = 10 };
            structure st2 = new structure { x = 10 };
            bool result = structure.ReferenceEquals(st1, st1);
            MyClass o = new MyClass { FirstName = "pralay", LastName = "patoria" };
            MyClass t = new MyClass { FirstName = "pralay", LastName = "patoria" };
            int ohc = o.GetHashCode();
            int thc = t.GetHashCode();
            result = ohc == thc;
            string strOne = "pralay";
            string strTwo = "patoria";
            int strOneHC = strOne.GetHashCode();
            int strTwoHC = strTwo.GetHashCode();
            int xor = strOneHC ^ (strTwoHC);
            bool res = strOne.GetHashCode() == strTwo.GetHashCode();
            object obj = new MyClass();
            Console.WriteLine(obj.ToString());
            //TestXOR.Person.Test();
            check checkLength = (int x, string s) => s.Length > x;
            bool r = checkLength(5, "pralay");
            Test(null);
            float ii = 1f;
            double jj = 1;
            result = ii == jj;


            int i = 13;
            int j = 11;
            int z = i ^ j;
            i = 2;
            j = 4;
            z = i ^ j;
            z = z >> 1;
            Console.WriteLine(z);
        }
Ejemplo n.º 2
0
 public void Func(ABC obj)
 {
     a = obj.a;
 }