Architect Arithmetic

In this project, when I finish the first task and try to run it, an error occurs.

my code:


**using System;**

namespace ArchitectArithmetic
{
  class Program
  {
    public static void Main(string[] args)
    {
      static double Rect(double length, double width)**
     {
       length * width;
     }
    }
  }
}

the error message:

Program.cs(9,7): error CS8652: The feature ‘static local functions’ is
currently in Preview and unsupported. To use Preview features, use
the ‘preview’ language version. [/home/ccuser/workspace/csharp-archite
ct-arithmetic/ArchitectArithmetic.csproj]

I am a total beginner in C#, but I think the error is asking me to use “preview’ language version” ?
I want to know how to do it, or if there is still another way to solve the problem. (or maybe skip this project and move on to the next one?)
Much thanks!

Hello @2502541822! Welcome to the forum. If you could post your code again using the </> icon, it would help us to be able to see exactly what your code looks like. It’s easiest to click the </> first, and then paste your code in the space indicated. It preserves formatting, and special characters like [], so they don’t look like .

I believe though, that your error is caused by your placement of the static double Rect() method. The method should be located inside the Program class, but not inside the Main method.

3 Likes

Sorry for the format.
My problem is solved, thank you!

2 Likes