Exemplo n.º 1
0
 public void Serialize(Person t1)
 {
     BinaryFormatter f = new BinaryFormatter();
     using (Stream stream = new FileStream(
         @"..\..\x.bin", FileMode.Create))
     {
         f.Serialize(stream, t1);
     }
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     Person per = new Person("Ivan", 36);
     Person per1 = new Person("Jhon", null);
     Person per2 = new Person("Pesho");
     Console.WriteLine(per);
     Console.WriteLine(per1);
     Console.WriteLine(per2);
 }
Exemplo n.º 3
0
        static void Main()
        {
            Person p = new Person("Vader");
            Person p1 = new Person("Smoke", null);
            Person p2 = new Person("Kano", 32);

            Console.WriteLine(p); //invokes ToString() method automatically
            Console.WriteLine(p1);
            Console.WriteLine(p2);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            var person = new Person("Haralambi Stamatov Prokopiev", 35);
            Console.WriteLine("Here is the person:");
            Console.WriteLine(person);
            Console.WriteLine();

            person = new Person("Haralambi Stamatov Prokopiev");
            Console.WriteLine("Here is the same person without age defined:");
            Console.WriteLine(person);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Person pesho = new Person("Petar Dimitrov", 15);
            Person mariq = new Person("Mariq Petrova", null);
            Person grigor = new Person("Grigor Vasilev");

            Console.WriteLine(pesho);
            Console.WriteLine();

            Console.WriteLine(mariq);
            Console.WriteLine();

            Console.WriteLine(grigor);
            Console.WriteLine();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.Title = "People";

            Person[] people = new Person[]{
                new Person("Jaklin"),
                new Person("Kalin", 24),
                new Person("Yulia", 21),
                new Person("Georgi"),
                new Person("Victoria", 20)
            };

            int index = 0;foreach (var person in people)
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen + index;
                Console.WriteLine(person);
                index++;
            }

            Console.WriteLine();
            Console.ResetColor();
        }
Exemplo n.º 7
0
        static void Main()
        {
            Person t1 = new Person(25, "Ivan Ivanov");
            Person testPerson2 = new Person("Minka Minkova");

            t1.AddCourse(Courses.chemistry);
            t1.AddCourse(Courses.literature);
            foreach (var course in t1.Courses)
            {
                Console.WriteLine(course);
            }
            Console.WriteLine();

            Serializer temp = new Serializer();
            temp.Serialize(t1);
            Person des = temp.Deserialize();
            Console.WriteLine(des.Age);
            Console.WriteLine(des.Name);
            foreach (var course in des.Courses)
            {
                Console.WriteLine(course);
            }
        }
 internal static void Main()
 {
     Person batman = new Person();
     batman.Name = "batman";
     Console.WriteLine(batman);
 }
Exemplo n.º 9
0
        //Create a class Person with two fields – name and age. Age can be left unspecified (may contain null value. 
        //Override ToString() to display the information of a person and if age is not specified – to say so. 
        //Write a program to test this functionality.

        static void Main()
        {
            Person p = new Person("Nadya");
            Console.WriteLine(p.ToString());
        }