zoukankan      html  css  js  c++  java
  • 问题集锦

    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

     

查看全文
  • 相关阅读:
    Mac 中 go env 找不到 GOROOT
    git log 中想要更改历史 日志
    Go 中 生成随机数的坑 rand.seed() rand.intn()
    HTML 首页倒三角形导航块
    HTML overflow:hidden
    HTML padding ,margin
    JavaScript 通过关系找标签
    JavaScript Dom编程根据属性找节点
    javascript String
    HTML 标签包含规范,规避脱标流,图片和文字垂直居中对齐,
  • 原文地址:https://www.cnblogs.com/yuanws/p/1670669.html
  • Copyright © 2011-2022 走看看