++++++++++ogogdliin class-d baiguulagch zarlaj ogsn lab3+++++++++++++++++++++

2011-09-09 14:12

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lab3
{
    class Program
    {
        public class Person
        {
            private string name;
            private int age;
            private string gender;
            private string phone;
            public Person()// default baiguulagch
{
Console.WriteLine("default baiguulagch duudagdlaa.");
name = "";
age = 0;
gender = "";
phone = "";
}
public Person(string name1, int age, string gender, string phone)
{
Console.WriteLine("2-r baiguulagch duudagdlaa");
this.name = name1;
this.age = age;
this.gender = gender;
this.phone = phone;
}

            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            public int Age
            {
                get { return age; }
                set { age = value; }
            }
            public string Gender
            {
                get { return gender; }
                set { gender = value; }
            }
            public string Phone
            {
                get { return phone; }
                set { phone = value; }
            }
            public void input()
            {
                Console.Write("Ner:");
                name = Console.ReadLine();
                Console.Write("Nas:");
                age = Convert.ToInt32(Console.ReadLine());
                Console.Write("Huis:");
                gender = Console.ReadLine();
                Console.Write("Utasnii dugaar:");
                phone = Console.ReadLine();
            }
            public void print()
            {
                Console.WriteLine("{0,15:c}{1,5:N0}{2,10:c}{3,12:c}", name, age, gender, phone);
            }
        }

        static void Main(string[] args)
        {
            Person p = new Person();
            p.input();
            p.print();
            p.Name = "Tungaa";
            p.Age = 23;
            p.print();
            Console.Read();
        }
    }
}

      
   
 

Ангилал : сүлжээ хичээл | Нийтэлсэн : kmtsmzb2 G.Ganbayar | Уншсан (161) | Өмнөх бичлэг |

Сэтгэгдэл

Сэтгэгдэл бичих

Таны нэр :
Таны э-мэйл хаяг : Ил харагдахгүй.
Сэтгэгдэл