我在运行此代码时遇到编译错误:
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
private Dictionary<string, string> _dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); // let's ignore case when comparing.
protected void Page_Load(object sender, EventArgs e)
{
using (var reader = new StreamReader(File.OpenRead(@"C:/dictionary.csv")))
{
while (!reader.EndOfStream)
{
string[] tokens = reader.ReadLine().Split(';');
_dictionary[tokens[0]] = tokens[1];
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string output;
if (_dictionary.TryGetValue(TextBox1.Text, out output))
{
TextBox2.Text = output;
}
else
{
TextBox2.Text = "Input not recognised";
}
}
}
}
这是编译器错误消息:CS1061:'ASP.webform1_aspx'不包含'TextBox1_TextChanged'的定义,并且找不到扩展方法'TextBox1_TextChanged'接受类型为'ASP.webform1_aspx'的第一个参数(您是否缺少使用指令还是汇编参考?)
这是什么意思,我该如何纠正?谢谢
在Visual Studio的Form上,很可能在您TextBox1_TextChanged
的TextChanged
属性中声明了一个方法TextBox
,而没有实现。
您可能已经拥有该实现(一个空方法),然后将其删除,而没有在Visual Studio的UI中删除对其的引用。因此,在Visual Studio中打开您的Form,单击TextBox1
,在TextChanged
属性中查找值并将其删除。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句