︻┳═一 如何判断一个数组为空
String[]   aa;   
                         //if   (aa[0]   ==   null) 
                         if   (aa[0]   ==   null) 
                         { 
                                     Response.Write( "aa是空滴 "); 
                         }   
 上面的写法都不行! 
 该怎么判断呢?
------解决方案--------------------zzlcn() ( ) 信誉:79    Blog  2007-01-31 12:15:01  得分: 0         
    上面的都不行! 
 我的那个数组是从其他类中返回的,某些情况下会返回 null 值   
 这个时候就需要判断数组是否为空          
 我的那个数组是从其他类中返回的,某些情况下会返回 null 值 
 这句话什么意思 是返回个null还是数组中有null值?   
 private string[] test() 
 { 
   string[] str = new string[5]; 
   return str; 
 }   
 private string[] test1() 
 { 
  return null; 
 } 
 LZ上面两个方法返回的东西不一样.一个是初始过大小的数组一个是null.   
 如果是第一种方法返回 判断如下: 
 private void Page_Load(object sender, System.EventArgs e) 
 { 
 	string[] aa = this.test(); 
 	bool bolTemp = false;   
 	foreach (string str in aa) 
 	{ 
 	    if (!String.IsNullOrEmpty(str)) 
 	    { 
 		bolTemp = false; 
 		break; 
 	     } 
 	     else 
 		bolTemp = true; 
 	}   
 	if (bolTemp) 
 	{ 
 	    Response.Write( "aa是空滴 "); 
 	} 
 }   
 private string[] test() 
 { 
 	string[] str = new string[5]; 
 	for(int i = 0; i  < str.Length; i++) 
 	{ 
 		str[i] = i +  " "; 
 	} 
 	return str; 
 } 
 第二种的返回就更简单啦 
 if( this.test1() == null) 
    Response.Write( "aa是空滴 ");