zoukankan      html  css  js  c++  java
  • C# No.3

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace myclass
    {
      class mc
      {
        private
        int testnum1;
        int testnum2;
        public mc(int i)
      {
        testnum1 = i;
        testnum2 = 0;
      }
        public mc()
          : this(5)
        {
          testnum2 = 7;
        }
        public void show()
        {
          Console.WriteLine("{0} {1}",testnum1,testnum2);
        }
      }

    class test
    {
    static void Main()
    {
    mc a = new mc(20);
    mc b = new mc();
    a.show();
    b.show();
    }
    }
    }

    Font anotherFont = new Font( "Courier", 12.0f );

    using ( anotherFont )

    { // use anotherFont } // compiler calls Dispose on anotherFont

    // using anotherFont here will fail

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication3
    {
    class Program
      {
        public static void getnum(int a,int b,int c)
        {
          a = 10;
          b = 20;
          c = 30;
        }
    static void Main(string[] args)
    {
      int a = 1;
      int b = 2;
      int c = 3;
      getnum(a, b, c);
      Console.WriteLine("{0} {1} {2}", a, b, c);
    }

    }
    }

    class Program
    {
       public static void getnum(ref int a,ref int b,ref int c)    // ref
      {
        a = 10;
        b = 20;
        c = 30;
      }
        static void Main(string[] args)
        {
          int a = 1;
          int b = 2;
          int c = 3;
        getnum(ref a,ref b,ref c);                                        // ref
        Console.WriteLine("{0} {1} {2}", a, b, c);
    }

    }
    }

    // out 可不赋初值

    //ref 必须赋初值

    //  ref 和 out 可在同意函数中混合使用

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace ConsoleApplication4
    {
    public class A
    {
    public virtual void print()
    {
    Console.WriteLine("Parent Method");
    }
    }

    public class B : A
    {
    public void child()
    {
    Console.WriteLine("Child Method");
    }

    public override void print()
    {
    Console.WriteLine("Overriding child method");
    }
    }
    class Program
    {
    static void Main(string[] args)
    {
    A a = new A();
    B b = new B();
    a.print();
    b.print();
    }
    }
    }

  • 相关阅读:
    ASP.NET常见安全缺陷集锦[转]
    林黛玉出家:给予中国给予我们的警示![摘]
    关于管理 关于经营 还有很多东西都无从做好
    ASP.NET 2.0的新增服务、控件与功能
    将可视的DataGrid、DataList等的规范表数据导出并写入xls或doc格式保存
    2006全球最具影响力品牌
    .NET环境下水晶报表使用总结[转]
    Asp.net(C#)分层——基础类
    Asp.Net传参方式小结
    MSN签名都成了广告位
  • 原文地址:https://www.cnblogs.com/yi-jie/p/4378811.html
Copyright © 2011-2022 走看看