欢迎访问我的博客 https://javascript.shop

重新学习基础:草稿1

原文发布时间为:2008-11-20 —— 来源于本人的百度文章 [由搬家工具导入]

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

using System.Threading;

using System.Text.RegularExpressions;
namespace baidu
{
    public delegate void MyDelegate(string input);
    class Program
    {
        static void Main(string[] args)
        {
            //int a = Convert.ToInt32(Console.ReadLine());

            //for (int i = 0; i < a; i++)
            //{
            //    for (int j = 0; j < a - i - 1; j++)
            //        Console.Write(" ");
            //    for (int k = 1; k <= 2 * i + 1; k++)
            //        Console.Write("*");
            //    Console.WriteLine();
            //}
            //string s = "我跟你和他是咱们";
            //s = System.Text.RegularExpressions.Regex.Replace(s,@"我|你|他|咱", "");
            //Console.WriteLine(s);
            //Console.ReadLine();
         //Thread thrd=new Thread(new ThreadStart(hello));
         //thrd.Start();
         ////thrd.Priority = ThreadPriority.Highest;
         //if (thrd.IsAlive)
         //    thrd.Abort();
         ////if (thrd.ThreadState == ThreadState.Running)
         ////    thrd.Suspend();
         ////if (thrd.ThreadState == ThreadState.Suspended)
         ////    thrd.Resume();

         //Console.ReadKey();
            //string t = "sdf1234sdf12sd12";
            //t = System.Text.RegularExpressions.Regex.Replace(t, @"\d+[a-z]+|[A-Z]+", "");
            //Console.WriteLine(t);
            //Console.ReadLine();
//            string i = @"Live for nothing,
//die for something";
//            Regex r3 = new Regex("^Live for nothing,\r\ndie for something$");
//            Console.WriteLine("r3 match count:" + r3.Matches(i).Count);
//            Console.ReadLine();
            B b1 = new B("1","2");
            Console.WriteLine(1.0*5/ 255);
            A a1 = new B();
            D d1 = new D();
            Console.WriteLine("{0:e}", d1.area());
            Console.WriteLine(d1.circle());
            a1.vfun();
            F f1 = new F();
            MyDelegate d2 = f1.create();
            f1.ca(d2, "love");
            G g1=new G();
            g1.CustomEvent+=new G.CustomEventHandler(CustomEvent1);
            g1.InvokeEvent();

            g1.CustomEvent-=new G.CustomEventHandler(CustomEvent1);
            g1.InvokeEvent();

            g1.CustomEvent+=new G.CustomEventHandler(CustomEvent2);
            g1.InvokeEvent();

            H h1 = new H("interface");
            Console.WriteLine(h1.add(1, 2));
            Console.WriteLine(h1.Point);
            Console.ReadLine();

        }

       
        protected static void hello()
        {
            Console.WriteLine("hello word!");
        }
        private static void CustomEvent1(object senders, EventArgs e)
        {
            Console.WriteLine("event1");
        }
        private static void CustomEvent2(object senders,EventArgs e)
        {
            Console.WriteLine("event2");
        }

    }
interface IMyexam
        {
            int add(int x, int y);
        }
        interface Imyexam2
        {
            string Point { get;set;}
        }
    public class A
    {
        public A()
        {
            Console.WriteLine("abcd");
        }
        public A(string a,string b)
        {
            Console.WriteLine("qqqq");
        }
      public void printf()
        {
            Console.WriteLine("printf");
        }
        public virtual void vfun()
        {
            Console.WriteLine("vfunbase");
        }
        public void printf(string input)
        {
            Console.WriteLine("{0}", input);
        }

    }
    public class B : A
    {
        public B()
        { }
      
        public B(string a,string b)
        {
            Console.WriteLine(a+b+"efg");
            printf();
            base.printf();
        }
      public new void printf()
        {
            Console.WriteLine("no printf");
        }
        public override void vfun()
        {
            Console.WriteLine("childfun");
        }
    }

    public abstract class C
    {
        public double area()
        {
            return (0);
        }
        public double circle()
        {
            return (0);
        }

     public abstract void DoWork(int i);
    }

    public   class D:C
    {
        private int a=4;
        public new double area()
        {
            return Math.PI * a * a;
        }
        public new double circle()
        {
            return Math.PI * 2 * a;
        }

public void DoWork(int i)

{

}

    }
    public sealed class E
    {
    }
    public class F
    {
        public MyDelegate create()
        {
            A a1 = new A();
            MyDelegate d1 = new MyDelegate(a1.printf);
            return d1;
        }
        public void ca(MyDelegate d, string input)
        {
            d(input);
        }
    }
    public class G
    {
        public delegate void CustomEventHandler(object senders, EventArgs e);
        public event CustomEventHandler CustomEvent;
        public void InvokeEvent()
        {
            if (CustomEvent != null)
                CustomEvent(this, EventArgs.Empty);
        }
    }
    public class H:IMyexam,Imyexam2
    {
        private string mystr;
        public H(string s)
        {
            mystr=s;
        }
        public int add(int x,int y)
        {
            return x+y;
        }
        public string Point
        {
            get{ return mystr;}
            set { mystr = value; }
        }
    }

}

posted @ 2017-07-11 00:33  孑孓子  阅读(102)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop