class CoOrds
{
public int x, y;
public CoOrds() {
x = 0;
y = 0;
}
public CoOrds(int x, int y) {
this.x = x;
this.y = y;
}
}
public CoOrds toto() {
CoOrds B = new CoOrds(3, 2);
return B;
}
private void result_Click(object sender, EventArgs e) {
l6.Text = "";
CoOrds D = new CoOrds();
D = toto();
l6.Text = "(" + D.x + "," + D.y + ")";
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Error 2 Inconsistent accessibility: return …
我有这个错误:
错误1"johny.Form1"不包含关于"Form1_Load的"和没有扩展方法的定义"Form1_Load的"接受类型"johny.Form1"的第一个参数可以找到(是否缺少using指令或程序集引用?)
这是表单设计者的代码:
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(456, 411);
this.Controls.Add(this.l6);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
Run Code Online (Sandbox Code Playgroud)
错误来自这一行:
this.Load += new System.EventHandler(this.Form1_Load);
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在c#中搜索数据库中的字符串
我想详细搜索一个名称..这就是搜索按钮的代码
private void button1_Click(object sender, EventArgs e)
{
string connectionString = Tyres.Properties.Settings.Default.Database1ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
DataTable dt = new DataTable();
SqlDataAdapter SDA = new SqlDataAdapter("SELECT * FROM table1 where Details like" + textBox1.Text, conn);
SDA.Fill(dt);
dataGridView1.DataSource = dt;
}
Run Code Online (Sandbox Code Playgroud)
以及我的应用程序示例 单击此处查看图像http://i45.tinypic.com/35aqa6t.jpg
我收到错误:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Run Code Online (Sandbox Code Playgroud)
附加信息:在"likeelie"附近的预期条件的上下文中指定的非布尔类型的表达式.
我试过这个代码来搜索一个整数(比如Quantity),它对我很有用:
private void button1_Click(object sender, EventArgs e)
{
string connectionString = Tyres.Properties.Settings.Default.Database1ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
DataTable dt = new DataTable();
SqlDataAdapter SDA …
Run Code Online (Sandbox Code Playgroud)