How to update C# from 9.0 to 11.0?

I want to use required here, but i get error that i need c# 11.0

using Microsoft.Build.Framework;
using System.Collections.Generic;
public class BackendClient
{
    public required string url { get; set; }
    public string appId;
    public string deviceId;

    public BackendClient(string url, string appId, string deviceId)
    {
        this.url = url;
        this.appId = appId;
        this.deviceId = deviceId;
    }

    public List<Category> getCategories()
    {

        return null;
    }
}

I have Mircrosoft Visual Studio version 17.7.2, .Net Framework version 4.8.09032, but in Assembly-CSharp i have this version of C#

9.0

I changed it on this

preview

And after previous this
preview
But after starting the unity project with code or assembly in visual studio it returns to 9.0 version. How can i change version to 11.0?

I’ve tested new lines in assembly, error with 11.0 version c# left after i added latest , but now i get error - missing compiler required member ‘system.runtime.compilerservices.required member attribute…ctor’ on this line - public class BackendClient

Unity uses C# 9 for the time being. If you want to go higher you’d have to compile C# 10/11 code to its own DLL and include that in your project.

1 Like