所以我想學習如何使用StringBuilder
類。我讀了它,它似乎比string
驚人!使用未分配的局部變量「strb」StringBuilder
我試圖創建中的其他按鈕StringBuilder
但它一直扔我的錯誤:
上線; expected" and Use of unassigned local variable "strb"
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 WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string nrmlString = "C#";
nrmlString += " This";
nrmlString += " is";
nrmlString += " a";
nrmlString += " Test";
nrmlString += " Thisss";
MessageBox.Show(nrmlString);
}
private void button2_Click(object sender, EventArgs e)
{
StringBuilder strb new StringBuilder("something");
strb.Append("Something else");
MessageBox.Show(strb.ToString());
}
}
}
局部變量未初始化。我必須手動初始化它們,但是如何? – VargaDev
您錯過了'=':'StringBuilder strb = new StringBuilder(「something」);' –