一.三种常用的字符串判空串方法:   1: bool isEmpty = (str.Length == 0); 
   2: bool isEmpty = (str == String.Empty); 
   3: bool isEmpty = (str == "");  哪种方法最快?   1. 1
   2. 2
   3. 3
二.根据线程安全的相关知识,分析以下代码,当调用test方法时i>10时是否会引起死锁?
public void test(int i) 

   lock(this) 
   {  
   if (i>10) 
    { 
      i--; 
      test(i); 
    } 
   } 
}    1. 会锁死
   2. 不会锁死
三.public sealed class SampleSingleton1
{
private int m_Counter = 0;
  private SampleSingleton1()
{
Console.WriteLine(""初始化SampleSingleton1。"");
}public static readonly SampleSingleton1 Singleton = new SampleSingleton1();public void Counter()
{
m_Counter ++;
}

以上代码实现了设计模式中的哪种模式?   1. 原型
   2. 抽象工厂
   3. 单键
   4. 生成器 

解决方案 »

  1.   

    lock 是什么意思啊,没用过
    我正郁闷.net多线程的取消按扭呢!
      

  2.   

    1. 普遍的观点是1最快, 但实际上一样快, 因为JIT会优化的
      

  3.   

    1会最快吗?1要算一下Length。。感觉像是2快。。
    呵呵。。还真不知道究竟哪个快。。
      

  4.   

    yahoo的在线笔试
    昨天在黄龙大酒店现场笔试,前20名有米拿,可惜刚好开会,去不了,郁闷
      

  5.   

    我觉得是三最快,只要比较低一个字符就行了,1要计算length,2要调String.Empty,不知道里面封装了什么东西
      

  6.   

    第一题是宇宙中最烂题,不信自己去比较一亿次。但答案一定是1最快,因为字符串比较第一步肯定是比长度,So:1、
    get_Lenth
    Int.Equals//两步完工2、3、
    String.op_equals
    String,Equals
    Steing._length
    Int.Equals
      

  7.   

    第三题当然是单例模式。不信你自己创建第二个实例出来看看,构造函数是私有的,又没有Create方法,摆明的单例。那个Counter除了计数还干什么?创建实例么?那个Counter就是利用单例做全局计数器的,最莫名其妙的是这个东西与生成器模式有什么关系。
      

  8.   

    1   1
    2   2 int here will not dead lock.If it's a object,dead lock will happen.
    3   3 Singleton Pattern
      

  9.   

    2   2 int here will not dead lock.If it's a object,dead lock will happen.能够帮我们解释1下吗?大哥!
      

  10.   

    2   2 int here will not dead lock.If it's a object,dead lock will happen.这个观点是错的
      

  11.   

    2   2 int here will not dead lock.If it's a object,dead lock will happen
    我觉得这个解释不对,有人能解释一下为什么2不会死锁吗?