如果我有一个空字符串即
string str = "";
string[] sss= str.Split(new char[] { '$' });
请问这样会错吗?
我在vs里跑没问题,但是挂到服务器上时,
string[] sss= str.Split(new char[] { '$' });
就出错了

解决方案 »

  1.   

    if(str!=null && str!=string.Empty())
    {
      string[] sss= str.Split(new char[] { '$' }); 
    }
      

  2.   

    string[] sss= str.Split('$'); 
      

  3.   


            if (!string.IsNullOrEmpty(str))
            {
                 string[] sss= str.Split(new char[] { '$' });
            }
      

  4.   

    直接使用string[] sss= str.Split('$'); 
      

  5.   


    string[] sss= str.Split('$'); 
      

  6.   

    用3楼
    if(str!=null && str!=string.Empty()) 

      string[] sss= str.Split(new char[] { '$' }); 
    }
    判断考虑更全