• 无法将类型"string"隐式转换为"bool"


    原代码:

             while (true)
            {
                Console.WriteLine("please add a string to ArrayList:");
                str1 = Console.ReadLine();
                if (str1="end")
                    break;
                arr.Add(str1);
                Console.WriteLine();
                for (int i = 0; i < arr.Count; i++)
                    Console.Write("{0}", arr[i]);
                Console.WriteLine("\n");
            }

    对以上的代码纠正,正确的代码为:       

    while (true)

          {
                Console.WriteLine("please add a string to ArrayList:");
                str1 = Console.ReadLine();
                if (str1=="end")
                    break;
                arr.Add(str1);
                Console.WriteLine();
                for (int i = 0; i < arr.Count; i++)
                    Console.Write("{0}", arr[i]);
                Console.WriteLine("\n");
            }

     现在运行正常了,希望对初学C# 的朋友们能有所帮助。
     

  • 相关阅读:
    python各种运算优先级一览表
    python数据类型之元组、字典、集合
    python数据类型之列表
    element.scrollHeight,scrollTop
    window.pageYOffset
    msdn getBoundingClientRect()
    js addEventListener
    js 原生滚动到指定元素(元素滚动到可视范围)
    css 选择器判断属性有无
    electron 查看版本信息
  • 原文地址:https://www.cnblogs.com/jianfangkk/p/1367243.html
Copyright © 2020-2023  润新知