• 问题集锦


    1. try {}里有一个return语句,那么紧跟在这个try后的finally {}里的code会 不会被执行,什么时候被执行,在return前还是后?
  • 答:会执行,在return前执行。

     

    2. short s1 = 1; s1 = s1 + 1;有什么错? short s1 = 1; s1 += 1;有什么错 ?

  • 答:short s1 = 1; s1 = s1 + 1;有错,s1是short型,s1+1是int型,不能显式
  • 转化为short型。可修改为s1 =(short)(s1 + 1) 。short s1 = 1; s1 += 1正
  • 确。

    long型没关系

  •  3. 获取分数最低的记录(可能有多条) SELECT TOP 1  with ties *
      FROM [test].[dbo].[users] order by score asc

    注:使用with ties 必须 有order by

  • 4. 虚函数

    static void Main(string[] args)
            {       A a = new A(); C c = new C();  }

       public class A
        {public A(){ Console.WriteLine("DEBUG: A constructing"); this.GetYear();}

          public virtual void GetYear(){Console.WriteLine("A");}
        }

        public class B:A
        {public B():base(){Console.WriteLine("DEBUG: B constructing");this.GetYear();}

          public override void GetYear(){Console.WriteLine("B");}
        }

        public class C : B
        {public C(){Console.WriteLine("DEBUG : C constructing");this.GetYear();}

           public override void GetYear(){Console.WriteLine("C");}

    }

    DEBUG: A constructing

    A

    DEBUG: A constructing

    C

    DEBUG: B constructing

    C

    DEBUG: C constructing

    C

     

  • 相关阅读:
    乱七八杂
    转化跟踪设置说明
    Photoshop图象切片保存为网页HTML(DIV+CSS布局)的方法
    HTTP 错误 403.14
    打开asp出现An error occurred on the server when processing the URL
    ADODB.Connection 错误 '800a0e7a'
    修改客户端连接的服务器IP地址(内部使用)
    关于云计算的10个常见问题解答
    云安全的11个挑战及应对策略
    如何鉴别一个区块链项目的真假?
  • 原文地址:https://www.cnblogs.com/yuanws/p/1670669.html
  • Copyright © 2020-2023  润新知