Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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