- Home /
Problem About Get and Set Methods
Hello guys,
I have problem about encapsulation. I have learned that in Java and as far as I know it works the same way in C# but in Unity It does not work. I will show you.
public class AnotherClass {
private int apple;
public void setApple(int app)
{
apple = app;
}
public int getApple()
{
return apple;
}
}
I am just trying to apply encapsulation but I am given these error messages. I want to create an "AnotherClass" instance and want to change the "apple" value via "setApple" method. I do this in java and C# without having any problems but in Mono I am given this error message: "Apple does not exist in the current context."
Can you please tell me what problem is ?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613195046im_/https://answers.unity.com/themes/thub/images/avi.jpg)