xxxxxxxxxxxxxxxxx

by shpendzzzzrrrzzzz on March 19th, 2012
No notes
Syntax: C#
Show lines - Hide lines - Show in textbox - Download
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace augusti2011
{
    public class Uppgift1
    {
        private string name = "tenta";
        static void a()
        {
            Person p = new Person("1", "anna");
            p.print();
        }
        static void b()
        {
            Person p1 = new Person("1", "data");
            new Uppgift1().bTemp(p1);
            p1.print();            
        }
        void bTemp(object imi)
        {
            Person p = imi as Person;
            p.Name = "Hata " + this;
        }
        static void c()
        {
            A a;
            Person p1 = new Person("1342", "anna");
            a = p1;
            p1 = a as Person;
            Console.WriteLine(f(new Person(), new Person()));
        }
        static bool f(object a, object b)
        { 
            return (a.GetType() == b.GetType());
        }
        static void d()
        {
            Temp.MyDelegate d = new Temp.MyDelegate(f);
            Person p1 = new Person("1342", "anna");
            IMyInterface imi = p1;
            bool b = d(new Person(), imi);
            Console.WriteLine(b.GetType());
        }
        static void e()
        {
            Person p1 = new Person("1342", "anna");
            Person p2 = new Person("1562", "fatso");
            p2 = p1;
            Console.WriteLine(p1 == p2);
        }
 
        static void Main(string[] args)
        {
            a();
            b();
            c();
            d();
            e();
        }
 
    }
}
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace augusti2011
{
    class A
    {
        public void print()
        {
            base.print();
            Console.WriteLine("Hej A");
        }
    }
}
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace augusti2011
{
    interface IMyInterface
    {
        object f(string str);
    }
}
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace augusti2011
{
    class Person : A, IMyInterface
    {
        private string id;
        private string name;
        public Person() { }
        public Person(string id, string name) 
        {
            Name = name;
            this.id = id;
        }
 
        public string Name { get { return name; } set { name = value; } }
        public new void print()
        {
            base.print();
            Console.WriteLine(Name);
        }
        public object f(string str)
        {
            return str.GetType();
        }
    }
}
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace augusti2011
{
    class Temp
    {
        public delegate bool MyDelegate(object x, object y);
    }
}
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS