Skip to content

Warning CS8632 The annotation for nullable reference types should only be used in code within a '#nullable' annotations context #26736

@JamalAPI

Description

@JamalAPI

Getting a warning on compile on Joke[]? jokes :

Warning CS8632 The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. WorkerService1 JokeService.cs 27

// The API returns an array with a single entry.
Joke[]? jokes = await _httpClient.GetFromJsonAsync<Joke[]>(
JokeApiUrl, _options);

also on Joke? joke = jokes?[0];

Removing the ? corrected the issue per the VS fix it recommendation.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions