0

I saw a question on this page https://www.toptal.com/c-sharp/interview-questions tryed to implement it in VS, here is is my full code:

 public class TopTalInterviewQuestions
 {
    //write code to calculate the circumference of the circle, without modifying the Circle class itself.
    Circle myCircle = new Circle();
    myCircle.??? // here VS does not help me        
}

public sealed class Circle
{
    //public Circle() { }
    private double radius;
    public double Calculate(Func<double, double> op)
    {
        return op(radius);
    }
}

Why i cant instantiate it and call the "Calculate" method? Please. explain it for a beginner.

Ewerton
  • 4,046
  • 4
  • 30
  • 56
  • The code as shown works, no idea what your problem is. Are you sure you provided everything that reproduces the issue? In particular: which compiler-error do you get? – MakePeaceGreatAgain Oct 09 '16 at 01:25
  • which version of VS are you using ? have you built your solution before trying to autocomplet? is autocomplete turned on to begin with? so many questions ... – Noctis Oct 09 '16 at 01:35
  • 1
    circle.Calculate(r => 2 * Math.PI * r) they have the "show the right answer with explanation" on their site as well... – Ondrej Svejdar Oct 09 '16 at 01:36
  • 2
    Possible duplicate of [Visual Studio 2015 Intellisense not working](http://stackoverflow.com/questions/31654667/visual-studio-2015-intellisense-not-working) –  Oct 09 '16 at 01:40
  • 1
    @OndrejSvejdar He's not asking _what arguments should I pass_ rather _why isn't auto-complete_ working I suspect –  Oct 09 '16 at 01:50
  • @MickyD - its somehow ambigious, the last sentence is "Why i cant instantiate it and call the "Calculate" method?", while in comment it is for sure complaint on intellisense. – Ondrej Svejdar Oct 09 '16 at 01:55
  • Get Resharper. Problem solved. – Krythic Oct 09 '16 at 02:11

1 Answers1

3

In this class:

public class TopTalInterviewQuestions
{
    //write code to calculate the circumference of the circle, without modifying the Circle class itself.
    Circle myCircle = new Circle();
    myCircle.??? // here VS does not help me        
}

When you're writing the line myCircle.???, you're trying to put a statement directly inside of a class declaration. You can't do that; statements need to go inside of methods.

Try something like this:

public class TopTalInterviewQuestions
{
    //write code to calculate the circumference of the circle, without modifying the Circle class itself.
    Circle myCircle = new Circle();
    public void MyMethod()
    {
        myCircle.???
    } 
}
Tanner Swett
  • 3,241
  • 1
  • 26
  • 32
  • Thanks @Tanner Swett, it was obvious for e now, when i stucked in the problem i was too tired to figure it out by myself. – Ewerton Oct 09 '16 at 21:22