Skip to content

Use the required keyword instead of String.Empty in options class #34588

@Daan5556

Description

@Daan5556

Description

In the PositionOptions class, maybe we want to use the required keyword because it's the more modern syntax.

Example:

public class PositionOptions
{
    public const string Position = "Position";

    public required string Title { get; set; } 
    public required string Name { get; set; } 
}

If you agree, we should also change the other instances of String.Empty.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/configuration/options.md

Document ID

dc7e3449-650b-d117-5eac-69e5ccb250cb

Article author

@tdykstra

Metadata

  • ID: ed39cb0e-aa85-8bba-ffb4-859b56a60723
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions