내 WFA에 다각형을 그리하려고를 찾을 수 있지만은그리기 다각형 C# OOP는 배열
class Driehoek : Figuur
{
Pen blackPen = new Pen(Color.Black, 3);
public void driehoek(Point p)
{
//this.x = 120;
//this.y = 50;
//this.width = 100;
//this.height = 100;
Point point1 = new Point(100, 150);
Point point2 = new Point(150, 100);
Point point3 = new Point(200, 150);
Point[] curvePoints =
{
point1,
point2,
point3,
};
}
public override void Teken(Graphics g)
{
g.DrawPolygon(blackPen, curvePoints);
// Error here is: The name 'curvePoints' does not exist in the current context
}
}
분명히 당신은 변수가 방법으로 범위가 클래스 수준 – TaW
에'driehoek'에서 curvePoints의 __declaration__을 이동해야합니다. 'blackPen'처럼 클래스 멤버로 선언하십시오. – SimpleVar
'curvePoints'는'driehoek' 메소드의 지역 변수입니다. 이렇게 Teken 메소드에서는 접근 할 수 없습니다. –