小编Ale*_*son的帖子

Foreach循环不能将字符转换为字符串

无论出于何种原因,这似乎都很简单.特别是Foreach循环给我这个错误"错误1无法将类型'char'转换为'string'".我做了一些研究,虽然它不想揭示它的自我.希望你们知道,非常感谢你的帮助.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace A_HtmlEditor
{
    public partial class Form1 : Form
    {
        AutoCompleteStringCollection data = new AutoCompleteStringCollection();

        public Form1()
        {
            InitializeComponent();
        }               

        // The error occurs in the foreach loop below    
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            webBrowser1.DocumentText = textBox1.Text;

            foreach(string s in textBox1.Text)
            {
                data.Add(s);
            } 
        }    
    }
}
Run Code Online (Sandbox Code Playgroud)

顺便说一下,当我在这里时,我想知道你们是否有可能知道是否有可能找出是否有按钮点击,例如关机按钮?或者,如果不可能,有一种方法可以知道计算机何时即将关闭.

我再一次感激,谢谢.

c# windows foreach

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

foreach ×1

windows ×1