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

推荐订阅源

博客园 - 叶小钗
D
Docker
GbyAI
GbyAI
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
小众软件
小众软件
Engineering at Meta
Engineering at Meta
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
B
Blog
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog

博客园 - 清雷

湘江老厨聚餐 我的青春 今日感想 东莞一日游 HP MC/SG 双机安装心得 周末的狂想 汉字转拼音的例子 回忆大学 Asp.Net下的DataGrid的多层表头 设置窗体背景图片,并且让图片随着窗体的大小的调整而调整大小 VS无法调试智能设备程序的解决方案 VS.Net下的新的单元测试工具-TestDriven.NET 怀念我的大学(2) 显示主窗体前显示登陆窗口的完美解决方案 windows消息大全 在.NET 中使用WIN32 API的宝库 一个封装的异步Socket客户端 开发.NET CF 蓝牙的通信模块 怀念我的大学(1)
一个很好的C#题目
清雷 · 2005-09-09 · via 博客园 - 清雷

Posted on 2005-09-09 11:37  清雷  阅读(1341)  评论(3)    收藏  举报

     看下面这段代码的输出结果是什么啊?

    class Class1
    
{
        
private static Class1 
            obj 
= new Class1(); 
        
public static int counter1; 
        
public static int counter2 = 0
        
private Class1() 
        

            counter1
++
            counter2
++
        }
 
        
public static Class1 getInstance() 
        

            
return obj; 
        }
 
        
        [STAThread]
        
static void Main(string[] args)
        
{
            Class1 obj 
= Class1.getInstance(); 
            Console.WriteLine(
"Class1.counter1=="+Class1.counter1); 
            Console.WriteLine(
"Class1.counter2=="+Class1.counter2); 
            
        }

    }

很多人都会答错的哦! 呵呵