[XCODE]
using
System;
using
System.Collections.Generic;
using
System.Collections.ObjectModel;
using
System.Linq;
using
System.Text;
namespace
ValueAndReferenceTypes
{
class Program
{
static void Main(string[] args)
{
}
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);
}
}
struct Point2
{
//Fields of the structure.
public int X;
public int Y;
// A custom constructor.
public Point2(int XPos, int YPos)
{
X = XPos;
Y = YPos;
}
//Display the current position.
public void Display()
{
Console.WriteLine("X = {0}, Y = {1}", X, Y);
}
}
static void ValueTypeAssignment()
{
Console.WriteLine("Assignment 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();
}
}
}
[/XCODE]
Not sure what I am doing Wrong but on line 66 I have an error that comes up that says:
'ValueAndReferenceTypes.Program.Point' does not contain a constructor that takes 2 arguments
Is there something I am over looking other than I am not calling it method in my main?
using
System;
using
System.Collections.Generic;
using
System.Collections.ObjectModel;
using
System.Linq;
using
System.Text;
namespace
ValueAndReferenceTypes
{
class Program
{
static void Main(string[] args)
{
}
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);
}
}
struct Point2
{
//Fields of the structure.
public int X;
public int Y;
// A custom constructor.
public Point2(int XPos, int YPos)
{
X = XPos;
Y = YPos;
}
//Display the current position.
public void Display()
{
Console.WriteLine("X = {0}, Y = {1}", X, Y);
}
}
static void ValueTypeAssignment()
{
Console.WriteLine("Assignment 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();
}
}
}
[/XCODE]
Not sure what I am doing Wrong but on line 66 I have an error that comes up that says:
'ValueAndReferenceTypes.Program.Point' does not contain a constructor that takes 2 arguments
Is there something I am over looking other than I am not calling it method in my main?