1
我不能找出這個代碼中的2個錯誤有人可以幫我嗎?錯誤:由於其保護級別C無法訪問Car.Form1#
錯誤1:Car.Form1是無法訪問由於其保護級別
錯誤2:?類型或命名空間名稱「點」找不到(是否缺少using指令或程序集引用
感謝您的幫助!
主要類
namespace Car
{
public partial class Form1 : Form
{
int x = 0;
int y = 500;
int turn = 0;
public Form1()
{
InitializeComponent();
}
public void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Right)
{
x += 32;
turn = 1;
}
else if (e.KeyCode == Keys.Left)
{
x -= 32;
turn = 2;
Wheel1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
Wheel2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
}
else
{
turn = 0;
}
if (x <= -250)
{
x = 1040;
}
else if (x >= 1041)
{
x = -250;
}
}
public void Form1_Load(object sender, EventArgs e)
{
}
}
}
汽車類
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Car
{
public class Car : Form
{
public Car(Form1 form1)
{
form1.Car.Location = new Point(form1.x, form1.y);
}
}
}
你是否知道你正在向表單添加表單? – terrybozzio
錯誤拼寫了錯誤消息。你寫了你認爲它所說的內容,而不是它真正說的內容。它抱怨Form1.Car,而不是Car.Form1。選擇好的標識符名稱是*重要*。 –