C# classes access data

What am I doing wrong?

1. Error (CS0103): The name 'xB' does not exist in the current context (line 83)

Do you might know what I am doing wrong?
I try to calculate the distance between two points, something very very simple.
With other things the data can be accessed.

question12.gh (6.9 KB)

you are using several variables you are declaring and assigning in the constructor.
If you want to use them in your methods you need to assign them in the constructor to a field/property of your class or feed them in your method as an input.

1 Like

Sorry, I was confused with something :blush: :zipper_mouth_face:

But this works fine :sunglasses:
Why does it not work all the time?
When it runs, it runs well.

It is not public, private or etc., right?

cause you are assigning in the constructor the variables to the class properties

1 Like

First of all, I am very glad that your responses are so quick; that I needed to say :slight_smile:

:thinking: I still cannot comprehend, this is similar to the previous example, right :thinking:
I am doing something wrong.


question12c.gh (8.1 KB)


question12cRE.gh (4.3 KB)

1 Like

You may want to have a look at some basic class examples:

1 Like