Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Collections Lists Lists

Mohammed Abdalla
Mohammed Abdalla
7,448 Points

Need help

Why I'm getting this error.

====================== MathHelpers.cs(11,35): error CS0103: The name Math' does not exist in the current context MathHelpers.cs(13,20): error CS0029: Cannot implicitly convert typeSystem.Collections.Generic.List' to `int' Compilation failed: 2 error(s), 0 warnings

MathHelpers.cs
using System.Collections.Generic;
namespace Treehouse.CodeChallenges
{
    public static class MathHelpers
    {
        public static int GetPowersOf2(int valuePassedIn)
        {
            List<int> powerOf2 = new List<int>();
            for(int i =1; i<= valuePassedIn; i++)
            {
                powerOf2.Add((int)Math.Pow(i, 2));
            }
            return powerOf2;
        }

    }
}

1 Answer

Mohammed Abdalla
Mohammed Abdalla
7,448 Points

Disregard it, I have fixed it Thanks