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

重新学习基础:草稿3(1)郁闷百度说太长了,所以我要分开发了

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

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

namespace baidu
{
    class Class6
    {
        //static void Main(string[] args)
        //{
        //    System.Console.WriteLine("Number of command line parameters = {0}", args.Length);

        //    foreach (string s in args)
        //    {
        //        System.Console.WriteLine(s);
        //    }
        //    Console.ReadLine();
        //}
        //static void Main()
        //{
        //    int i = 123;
        //    object o = i; // implicit boxing

        //    try
        //    {
        //        int j = (short)o; // attempt to unbox

        //        System.Console.WriteLine("Unboxing OK.");
        //    }
        //    catch (System.InvalidCastException e)
        //    {
        //        System.Console.WriteLine("{0} Error: Incorrect unboxing.", e.Message);
        //    }

        //    Console.ReadLine();
        //}

        //static void FillArray(out int[] arr)
        //{
        //    // Initialize the array:
        //    arr = new int[5] { 1, 2, 3, 4, 5 };
        //}

        //static void Main()
        //{
        //    int[] theArray; // Initialization is not required

        //    // Pass the array to the callee using out:
        //    FillArray(out theArray);

        //    // Display the array elements:
        //    System.Console.WriteLine("Array elements are:");
        //    for (int i = 0; i < theArray.Length; i++)
        //    {
        //        System.Console.Write(theArray[i] + " ");
        //    }

        //    Console.ReadLine();
        //}

        //static void FillArray(ref int[] arr)
        //{
        //    // Create the array on demand:
        //    //if (arr == null)
        //    //{
        //    //    arr = new int[10];
        //    //}
        //    // Fill the array:
        //    arr[0] = 1111;
        //    arr[4] = 5555;
        //}

        //static void Main()
        //{
        //    //// Initialize the array:
        //    //int[] theArray= { 1, 2, 3, 4, 5 };

        //    //// Pass the array using ref:
        //    //FillArray(ref theArray);

        //    //// Display the updated array:
        //    //System.Console.WriteLine("Array elements are:");
        //    //for (int i = 0; i < theArray.Length; i++)
        //    //{
        //    //    System.Console.Write(theArray[i] + " ");
        //    //}
        //    //char[] delimit = new char[] { ' ' };
        //    string s10 = "The cat sat on the mat.";
        //    //foreach (string substr in s10.Split(delimit))
        //    //{
        //    //    System.Console.WriteLine(substr);
        //    //}
           
        //    string[] str = s10.Split(' ');
        //    foreach (string substr in str)
        //    {
        //        Console.WriteLine(substr);
        //    }

        //    Console.ReadLine();
        //}

        //static void Main()
        //{
        //    string str = "A silly sentence used for silly purposes.";
        //    System.Console.WriteLine("'{0}'", str);

        //    bool test1 = str.StartsWith("a silly");
        //    System.Console.WriteLine("starts with 'a silly'? {0}", test1);

        //    bool test2 = str.StartsWith("a silly", System.StringComparison.OrdinalIgnoreCase);
        //    System.Console.WriteLine("starts with 'a silly'? {0} (ignoring case)", test2);

        //    bool test3 = str.EndsWith(".");
        //    System.Console.WriteLine("ends with '.'? {0}", test3);

        //    int first = str.IndexOf("silly");
        //    int last = str.LastIndexOf("silly");
        //    string str2 = str.Substring(first, last - first);
        //    System.Console.WriteLine("between two 'silly' words: '{0}'", str2);
        //    Console.ReadLine();
        ////}
        //static void Main()
        //{
        //    string[] sentences =
        //{
        //    "cow over the moon",
        //    "Betsy the Cow",
        //    "cowering in the corner",
        //    "no match here"
        //};

        //    string sPattern = "cow";

        //    foreach (string s in sentences)
        //    {
        //        System.Console.Write("{0,24}", s);

        //        if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
        //        {
        //            System.Console.WriteLine(" (match for '{0}' found)", sPattern);
        //        }
        //        else
        //        {
        //            System.Console.WriteLine();
        //        }
        //    }
        //    Console.ReadLine();
        //}


        //static void Main()
        //{
        //    string[] numbers =
        //{
        //    "123-456-7890",
        //    "444-234-22450",
        //    "690-203-6578",
        //    "146-893-232",
        //    "146-839-2322",
        //    "4007-295-1111",
        //    "407-295-1111",
        //    "407-2-5555",
        //};

        //    string sPattern = "^\\d{3}-\\d{3}-\\d{4}$";

        //    foreach (string s in numbers)
        //    {
        //        System.Console.Write("{0,14}", s);

        //        if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern))
        //        {
        //            System.Console.WriteLine(" - valid");
        //        }
        //        else
        //        {
        //            System.Console.WriteLine(" - invalid");
        //        }
        //    }

        //    Console.ReadLine();
        //}

        //static void Main()
        //{
        //    string str = "The quick brown fox jumped over the fence";
        //    System.Console.WriteLine(str);

        //    char[] chars = str.ToCharArray();
        //    int animalIndex = str.IndexOf("fox");
        //    if (animalIndex != -1)
        //    {
        //        chars[animalIndex++] = 'c';
        //        chars[animalIndex++] = 'a';
        //        chars[animalIndex] = 't';
        //    }

        //    string str2 = new string(chars);
        //    System.Console.WriteLine(str2);
        //    Console.ReadLine();
        //    int a = 1;
        //    SampleClass sc1 = (SampleClass)a;
        //}

        //static void Main()
        //{
        //    try
        //    {

        //        Digit d = new Digit(3);
        //        byte b = d;
        //        Console.WriteLine("{0}", b);
        //    }
        //    catch (System.Exception e)
        //    {
        //        System.Console.WriteLine("{0} Exception caught.", e);
        //    }
        //    Console.ReadLine();
        //}

        //static void Main()
        //{
        //    Complex num1 = new Complex(2, 3);
        //    Complex num2 = new Complex(3, 4);
        //    Chu chu1 = new Chu(4);
        //    Chu chu2 = new Chu(3);
        //    Chu chu3 = chu1 / chu2;


        //    // Add two Complex objects through the overloaded plus operator:
        //    Complex sum = num1 + num2;

        //    // Print the numbers and the sum using the overriden ToString method:
        //    System.Console.WriteLine("First complex number: {0}", num1);
        //    System.Console.WriteLine("Second complex number: {0}", num2);
        //    System.Console.WriteLine("The sum of the two numbers: {0}", sum);
        //    Console.WriteLine("The Chu of the two numbers: {0}", chu3);
        //    Console.ReadLine();
       
        //}
        //static void Main()
        //{
        //    Shape[] shapes =
        //{
        //    new Square(5, "Square #1"),
        //    new Circle(3, "Circle #1"),
        //    new Rectangle( 4, 5, "Rectangle #1")
        //};

        //    System.Console.WriteLine("Shapes Collection");
        //    foreach (Shape s in shapes)
        //    {
        //        System.Console.WriteLine(s);
        //    }
        //    Console.ReadLine();
        //}

        //static void Main()
        //{
        //    //Car[] cars = new Car[3];
        //    //cars[0] = new Car();
        //    //cars[1] = new ConvertibleCar();
        //    //cars[2] = new Minivan();
        //    //foreach (Car vehicle in cars)
        //    //{
        //    //    System.Console.WriteLine("Car object: " + vehicle.GetType());
        //    //    vehicle.DescribeCar();
        //    //    System.Console.WriteLine("----------");
        //    //}

        //    SampleClass2 obj2 = new SampleClass2();
        //    //obj2.Paint(); // Compiler error.

        //    IControl c = (IControl)obj2;
        //    c.Paint(); // Calls IControl.Paint on SampleClass.

        //    ISurface s = (ISurface)obj2;
        //    s.Paint(); // Calls ISurface.Paint on SampleClass.

        //    Console.ReadLine();
        //}

        //static void Main()
        //{
        //    // Declare a class instance box1:
        //    Box box1 = new Box(30.0f, 20.0f);

        //    // Declare an interface instance dimensions:
        //    IDimensions dimensions = (IDimensions)box1;

        //    // The following commented lines would produce compilation
        //    // errors because they try to access an explicitly implemented
        //    // interface member from a class instance:                  
        //    //System.Console.WriteLine("Length: {0}", box1.getLength());
        //    System.Console.WriteLine("Width: {0}", box1.getWidth());

        //    // Print out the dimensions of the box by calling the methods
        //    // from an instance of the interface:
        //    System.Console.WriteLine("Length: {0}", dimensions.getLength());
        //    System.Console.WriteLine("Width: {0}", dimensions.getWidth());

        //    Console.ReadLine();
        //}
        //static void Change(int[] pArray)
        //{
        //    pArray[0] = 888; // This change affects the original element.
        //    pArray = new int[5] { -3, -1, -2, -3, -4 };   // This change is local.
        //    System.Console.WriteLine("Inside the method, the first element is: {0}", pArray[0]);
        //}

        //static void Main()
        //{
        //    GouZao gz1 = new GouZao(4);
        //    int[] arr = { 1, 4, 5 };
        //    System.Console.WriteLine("Inside Main, before calling the method, the first element is: {0}", arr[0]);

        //    Change(arr);
        //    System.Console.WriteLine("Inside Main, after calling the method, the first element is: {0}", arr[0]);
        //    Bus b1 = new Bus();
        //    Bus.Drive();
        //    b1.inMethod();
        //    Third t = new Third();
        //    Console.ReadLine();
        //}
        static void Main()
        {
            CoOrds myCoOrds = new CoOrds(10, 15);
            myCoOrds.PrintCoOrds();
            Console.ReadLine();
        }


    }

    class SampleClass
    {
        public static explicit operator SampleClass(int i)
        {
            SampleClass temp = new SampleClass();
            // code to convert from int to SampleClass...

            return temp;
        }
    }

    class ZhuangHuan
    {
        public static explicit operator ZhuangHuan(string s)
        {
            ZhuangHuan temp = new ZhuangHuan();
            return temp;
        }
    }

    //struct Digit
    //{
    //    byte value;

    //    public Digit(byte value) //constructor
    //    {
    //        if (value > 9)
    //        {
    //            throw new System.ArgumentException();
    //        }
    //        this.value = value;
    //    }

    //    public static explicit operator Digit(byte b) // explicit byte to digit conversion operator
    //    {
    //        Digit d = new Digit(b); // explicit conversion
    //        System.Console.WriteLine("conversion occurred");
    //        return d;
    //    }
    //}
   //后续,没有后续无法运行。。。。

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