private void metroAddHumanStructButton_Click(object sender, EventArgs e)
        {
            HumanStruct currentHumanStruct = new HumanStruct();

            using (var unitOfWork = new UnitOWork(new GoDBContext()))
            {
                if (this.Controls.OfType <MetroTextBox>().All(textBox => textBox.Text != String.Empty))
                {
                    currentHumanStruct.id = Int32.Parse(metroHumanStructIdTextBox.Text);
                    currentHumanStruct.DB_Object_Symbol = metroGeneSymbolTextBox.Text;
                    currentHumanStruct.GOid             = Int32.Parse(metroHumanStructGoIdTextBox.Text);
                    Confirm confirm = new Confirm();
                    confirm.ShowDialog();
                    if (confirm.Result)
                    {
                        unitOfWork.HumanStructs.Add(currentHumanStruct);
                        unitOfWork.Complete();
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show(@"Invalid input values");
                }
            }
        }
 public HumanBeing(int age)
 {
     Human = new HumanStruct();
     Human.Age = age;
     if (age % 2 == 0)
     {
         Human.Name = "Batkata";
         Human.Gender = GenderEnum.Male;
     }
     else
     {
         Human.Name = "Matseto";
         Human.Gender = GenderEnum.Female;
     }
 }
Example #3
0
 static void Change(ref HumanStruct hs)
 {
     hs.age = 80;
 }
Example #4
0
        static void Main(string[] args)
        {
            //  checked
            //{
            //    short a =  short.Parse(Console.ReadLine());
            //    //a += 1000;
            //    //Console.WriteLine(a);

            //    short a1 = short.Parse(Console.ReadLine());
            //    a =  checked((byte)(a + a1));
            //    Console.WriteLine(a);
            //}

            //checked
            //{
            //    byte b = 255;
            //    b += 2;
            //    Console.WriteLine(b);
            //}

            //Foo(20, 12, 25, 23, 2.3, "hgfhgfhg");

            //Foo2(2,3,5);
            //Foo2(113,2,3,5,6);


            HumanStruct hStr = new HumanStruct();

            hStr.Init();
            // HumanStruct hStr2;//---no default values for params
            HumanStruct hStr2 = new HumanStruct();

            hStr2.Init();
            Console.WriteLine($"name { hStr.name } age { hStr.age }");
            //Console.WriteLine($"name { hStr2.name } age { hStr2.age }");

            Change(ref hStr);
            Console.WriteLine($"name { hStr.name } age { hStr.age }");

            Console.WriteLine("-------------------------------------");
            HumanClass hc = new HumanClass();

            hc.name = "Vasja";
            Console.WriteLine($"name { hc.name } age { hc.age }");
            ChangeClass(ref hc);
            Console.WriteLine($"name { hc.name } age { hc.age }");

            Console.WriteLine("-------------------------------------");

            hStr2               = hStr; //---its two different objects
            hStr.age            = 13;
            hStr.humanClass.age = 100;
            Console.WriteLine($"name { hStr.name } age { hStr.age }  humanClassAge {hStr.humanClass.age} hashCode {hStr.GetHashCode()}");
            Console.WriteLine($"name { hStr2.name } age { hStr2.age } humanClassAge {hStr.humanClass.age}   hashCode {hStr2.GetHashCode()}");

            Console.WriteLine("-------------------------------------");

            HumanClass hc2 = hc;//----its only one object and two references

            hc.age = 13;
            Console.WriteLine($"name { hc.name } age { hc.age }   hashCode {hc.GetHashCode()}");
            Console.WriteLine($"name { hc2.name } age { hc2.age }    hashCode {hc2.GetHashCode()}");

            DateTime zeroTime = new DateTime(1, 1, 1);
            DateTime dt       = new DateTime(1986, 12, 10);
            TimeSpan t        = dt - DateTime.Now;
            int      years    = (zeroTime + t).Year - 1;

            Thread.Sleep(200);
        }