예제 #1
0
파일: Program.cs 프로젝트: hemalsshah/OPPs
        public void SetData()
        {
            int i = 0;
            int j = 1;

            // this is value type
            CalculateValueType(i, j);
            Console.WriteLine(i.ToString());

            // this is ref type
            CalculateRefType(ref i, j);
            Console.WriteLine(i.ToString());

            // When passing object, it will be always a referance type
            MethodOverRidingChild a = new MethodOverRidingChild();

            a.TestValueTypeRefType = 10;
            CalculateObjectType(a);
            Console.WriteLine(a.TestValueTypeRefType.ToString());
        }
예제 #2
0
파일: Program.cs 프로젝트: hemalsshah/OPPs
 public void CalculateObjectType(MethodOverRidingChild a)
 {
     a.TestValueTypeRefType = 15;
 }
예제 #3
0
파일: Program.cs 프로젝트: hemalsshah/OPPs
        static void Main(string[] args)
        {
            #region ReadOnly Variable Implementation
            A a = new A();
            Console.WriteLine(a.variable);
            Console.ReadLine();
            return;

            #endregion

            #region HashTable and Dictionary
            // Dictionay VS HashTable
            // 1 Hastable will handle null value
            // 2 Both are storing key value pair

            //Dictionary<string, string> dic = new Dictionary<string, string>();
            //dic.Add("Name", "hemal");
            //dic.Add("Add", "Maninagar");

            //Hashtable hash = new Hashtable();
            //hash.Add("Name", "Hemal");
            //hash.Add("Add", "Maninagar");


            //string str1 = Convert.ToString(hash["A1"]);
            //str1 = hash["Add"].ToString();

            //string str = dic.Where(c => c.Key == "Add").FirstOrDefault().Value;
            //str = Convert.ToString(dic["A1"]);
            #endregion

            #region Sealed Class
            //SealedClass s = new SealedClass();
            //s.SealedClassMethod();
            #endregion

            #region Static Class
            //StaticClass.StaticClassMethod();
            #endregion

            #region Exception Handling
            //try
            //{
            //    int i = 0;
            //    int j = 1 / i;
            //    //divideby 0 error
            //}
            //catch (DivideByZeroException ex)
            //{
            //    Console.WriteLine("Divide By Zero");
            //}
            //catch
            //{
            //    Console.WriteLine("Default Catch");
            //}
            #endregion

            MethodOverRidingBase Base = new MethodOverRidingBase();
            Base.Calculate(); // MethodOverRidingBase

            MethodOverRidingChild Child = new MethodOverRidingChild();
            Child.Calculate(); // MethodOverRidingChild

            //MethodOverRidingChild BaseChild = new MethodOverRidingBase();
            //BaseChild.Calculate(); //MethodOverRidingBase

            MethodOverRidingBase ChildBase = new MethodOverRidingChild();
            ChildBase.Calculate(); //MethodOverRidingBase


            //B b = new B();
            //b.Clear();

            //C c = new C();
            //c.Print();

            //D d = new D();
            //d.Print();

            //A d1 = new D();
            //d1.Print();

            //ImplemtInterface I = new ImplemtInterface();
            //I.GetData();

            Console.Read();
        }