我想要一個消息框彈出顯示從用戶接受的字符串的第一個字符通過文本框,當用戶單擊消息框的確定按鈕時,下一個字符彈出消息直到達到空。無法從字符轉換爲字符串
我已經創建了這個程序,但由於顯而易見的原因,它給出了以下錯誤: 「無法從'字符'轉換爲'字符串'」 請提出一些更改。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace loop_Message
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void submit_Click(object sender, EventArgs e)
{
string str;
str = stringTxt.Text;
for (int i = 0; str[i] != null; i++)
{
MessageBox.Show(str[i]);
}
}
}
}
Consder讀取C#和C++之間的區別 - 其中一種語言有0個終止字符串,另一個沒有。 – 2013-02-26 07:59:24
試試這個MessageBox.Show(str [i] .ToString()); – 2013-02-26 08:02:18