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

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 张少峰

在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了么?”

  我再一看,靠!

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

  耻辱啊,活该被鄙视。

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

  志之以为戒。