• 重新学习基础:草稿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, die 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; }
            }
        }

    }

  • 相关阅读:
    前端插件之Datatables使用--上篇
    Django websocket之web端实时查看日志实践案例
    前端插件之Select2使用
    前端插件之Bootstrap Dual Listbox使用
    简单易落地且对运维友好的配置中心方案
    Devops-运维效率之数据迁移自动化
    中小团队基于Docker的Devops实践
    nginx第七篇:Nginx集群(负载均衡)、集群介绍、构建集群、nginx默认分发算法、nginx基于请求头的分发算法
    nginx之旅(第六篇):nginx优化--nginx优化目的、工作进程优化、长连接设置、数据压缩、客户端缓存
    nginx之旅(第五篇):URL重写介绍、URL重写场景、URL重写语法
  • 原文地址:https://www.cnblogs.com/handboy/p/7148420.html
Copyright © 2020-2023  润新知