나는 책을 따라 가면서 시작하기가 다소 어려운 초보자입니다. 나는 책을 읽고 코드가 무엇을하는지보기 위해 코드를 컴파일 할 것이다. 저는 구조체의 섹션, 특히 구조체 변수에 있습니다. 다음 코드는 point does not take two arguments
입니다. 누군가 나를 놓치거나 부정확 한 점을 발견하도록 도울 수 있습니까? 감사. 당신이 인수를 호출하기 때문에구조 변수 만들기 C#
using System;
class Program
{
static void Main(string[] args)
{
// Create an initial Point.
Point myPoint;
Point p1 = new Point(10, 10);
myPoint.X = 349;
myPoint.Y = 76;
myPoint.Display();
// Adjust the X and Y values.
myPoint.Increment();
myPoint.Display();
Console.ReadLine();
}
// Assigning two intrinsic value types results in
// two independent variables on the stack.
static void ValueTypeAssignment()
{
Console.WriteLine("Assigning value types\n");
Point p1 = new Point(10, 10);
Point p2 = p1;
// Print both points.
p1.Display();
p2.Display();
// Change p1.X and print again. p2.X is not changed.
p1.X = 100;
Console.WriteLine("\n=> Changed p1.X\n");
p1.Display();
p2.Display();
}
}
struct Point
{
// Fields of the structure.
public int X;
public int Y;
// Add 1 to the (X, Y) position.
public void Increment()
{
X++; Y++;
}
// Subtract 1 from the (X, Y) position.
public void Decrement()
{
X--; Y--;
}
// Display the current position.
public void Display()
{
Console.WriteLine("X = {0}, Y = {1}", X, Y);
}
}
인수를 취하는 Point의 생성자가 없습니다. – Joe