• 0

C# again..


Question

public Point(int x, int y)

{

this.x = x;

this.y = y;

}

...that's a constuctor for a structure...what I want to know though is why is 'this' needed in there?...and what does it do?...*took me long enough to get 'this''s uses to call methods and stuff, now this...:ermm: *

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

this.x refers to the int x in the class not the parameter. You'll need this coz your parameters are also called x and y. Here it's mainly to differ.

Coz if you do

x = x;

y = y;

Guess what it means and does.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.