惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
S
Securelist
P
Proofpoint News Feed
D
DataBreaches.Net
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Project Zero
Project Zero
A
About on SuperTechFans
罗磊的独立博客
WordPress大学
WordPress大学
月光博客
月光博客
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 三生石上(FineUI控件)
F
Fortinet All Blogs
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
AI
AI
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Help Net Security
Help Net Security
T
Tor Project blog
V
Vulnerabilities – Threatpost
C
Cisco Blogs
I
Intezer
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
雷峰网
雷峰网
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
T
Threat Research - Cisco Blogs
B
Blog RSS Feed
博客园 - 叶小钗
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Simon Willison's Weblog
Simon Willison's Weblog
C
CERT Recently Published Vulnerability Notes
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic

博客园 - 张少峰

在linuxdeepin10.12下源码安装bochs-2.4.6 设置pppoe时遇到“Oh, dear, I don't see the file '/etc/ppp/pppoe.conf' anywhere.”时的解决方法 安装ubuntu10.10时遇到ubi partman crashed,ubi-partman failed with exit code 141的解决方案 Reflector插件FileDisassembler汉化修改版 解压用Sixxpack2.2压缩过的程序,拿原始程序集 - 张少峰 - 博客园 利用网页挂马拿服务器的一种设想 第一次上首页,发一个玩具级的持久化工具~ python一些细微的东西 IndentationError: unindent does not match any outer indentation level Request的几种路径属性 一个方法返回多个值的解决方法 值类型与引用类型 用反射把程序集中一些泛型类实例化,怎么确定实例的类型? 父类实现IComparable<T>接口,子类无法使用~ [转载]谓词和操作(c#版) 静态变量的继承 XPath初学笔记(四) XPath初学笔记(三) XPath初学笔记(二)
糗事的教训:做事一定要细心细心再细心
张少峰 · 2010-07-18 · via 博客园 - 张少峰

  今天被一个朋友狠狠捉弄了一把,所以才有此感慨,事情是这样的,一个朋友发给我一段代码,问我执行结果。代码如下:

using System;
using System.Collections.Generic;
using System.Text;namespace Test
{
    
class Program
    {
        
static void Main(string[] args)
        {
            Subclass sub 
= new Subclass();
            Console.ReadLine();
        }
    }
public class BaseClass
    {
        
public BaseClass()
        {
            Console.WriteLine(
"基类构造函数");
        }
    }
public class Subclass
    {
        
public Subclass()
            : 
base()
        {
            Console.WriteLine(
"子类构造函数");
        }
    }
}

  我一看,这也太小看咱了,咱好歹.net也折腾三年多了,不至于这么基础的知识也不知道吧。不就是子类和基类的构造函数调用顺序的问题吗,当前是基类的构造函数先执行,执行结果自然就是: 

  结果被朋友嘲笑了一番,我当然不服,与之争辩。朋友建议我运行一下看看,我一想也是,事实说明一切嘛,于是建项目,复制粘贴,运行,然后傻眼了,结果竟然是:

   不可能!基类构造函数怎么会不执行,难道记错了?赶紧上网搜索一下,没错啊,基类的构造函数应该执行,而且会先执行。于是面对不容置疑的理论和同样不容置疑的结果,我迷糊了,赶紧虚心求教,结果朋友笑翻了,道:“你再仔细看看,Subclass继承BaseClass了么?”

  我再一看,靠!

  这个贱人给两个类起了两个这么贱的名字,结果俺一时不察,竟然阴沟里翻船了。

  耻辱啊,活该被鄙视。

  技术上任何时候都不能马虎,做事一定要细心细心再细心。再难的技术,只要用心,总有学会的时候。不过不管你技术学到多牛的程度,如果不具备技术之外一些基本素质的话,早晚会犯下让自己后悔莫及的低级错误。

  志之以为戒。