测试代码

static void Main(string[] args)
        {
            string[] ss = new string[]{ "", " ", "  ", string.Empty };
            for (int i = 0; i < ss.Length; i++)
            {
                for (int j = i+1; j < ss.Length; j++)
                {
                    bool re=false;
                    if (ss[i] == ss[j])
                        re = true;

                    Console.WriteLine("{0}与{1}是否相等{2}", i.ToString(), j.ToString(), re.ToString());
                }
            }
            Console.ReadLine();
            for (int i = 0; i < ss.Length; i++)
            {
                try
                {
                    double p = Convert.ToDouble(ss[i]);
                    Console.WriteLine("{0}   {1}", i.ToString(), p.ToString());
                }
                catch (System.Exception ex)
                {
                    continue;    
                }
            }
            Console.ReadLine();

            for (int i = 0; i < ss.Length; i++)
            {
                try
                {
                    double p;
                    double.TryParse(ss[i], out p);
                    Console.WriteLine("{0}   {1}", i.ToString(), p.ToString());
                }
                catch (System.Exception ex)
                {
                    continue;
                }
            }
            Console.ReadLine();
        }
View Code

相关文章:

  • 2021-12-18
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
猜你喜欢
  • 2022-02-23
  • 2021-07-20
  • 2022-02-26
  • 2021-09-12
  • 2022-12-23
相关资源
相似解决方案