-5

I can't get it to work! When I type this code in main to call the method "CreateJuice":

var totalSum = OrangeJuice.CreateJuice(AddOranges());

I get this error: The name AddOranges does not exist in the current context. I need help calling my method.

How can I call my CreateJuice method?

LittleBird
  • 65
  • 9
  • Where do you define `CreateJuice` and `AddOrange`? You don't show the class name. You showed things that don't matter and hidden things that matter. – Zein Makki Nov 30 '16 at 20:41
  • Since AddOranges is a staic method you need to preface it with the name of the class. So if the class is Fruit, then calling Fruit.AddOranges() would return your list. – Jason Massey Nov 30 '16 at 20:41
  • 4
    "AddOranges does not exist in the current context" -- Maybe if you called it by its actual name, `AddOrange()`? That is, assuming that's not a typo from typing up the question. If it is, then look at the `classname.method()` suggestion above. – 15ee8f99-57ff-4f92-890c-b56153 Nov 30 '16 at 20:43

1 Answers1

0

you need to qualify the method call with the class name since it's static

var totalSum = OrangeJuice.CreateJuice(OrangeJuice.AddOranges());

I'm assuming they are in the same class.

Fran
  • 6,440
  • 1
  • 23
  • 35