Shawn
new to c#! not too sure why i can't call my method from class
- Your
Addition
method is taking two parameters, which happened to be named the same as your private fields, but are distinct values. Because you named the parameters the same, they're taking precedence over your private fields, causing confusion. If you want to add your two private fields together, you'd just do so, with no parameters for your Addition
method.
- If it is the case that you want to add the private fields together, you wouldn't call Class.Method()
- that would be for a static method, not an instance method. Instead, you'd call instance.Method()
, as in calc1.Addition()
in this case9 replies