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# Objects Methods Return Values

Hassan Wattar
Hassan Wattar
1,166 Points

error CS1520

i keep on getting this error even though their is no wrong thing in my code, here is my code: namespace TreehouseDefense { class Point { public readonly int X; public readonly int Y;

    public point(int x, int y)  
    {
        X = x;
        Y = y;
    }
}

}

and here is the compiler error:

mcs -out:TreehouseDefense.exe *.cs && mono TreehouseDefense.exe point.cs(8,10): error CS1520: Class, struct, or interface method must have a return type Complination failed: 1 error(s), 0 warnings

4 Answers

Hassan Wattar
Hassan Wattar
1,166 Points

that isn't the problem but thanks for helping

Hey there, I know this is a bit old but the problem is that when you declared public point(int x, int y)

it has a lowercase p and it should be upper case like so:

public Point(int x, int y)