diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs index ebab8d554de25e..be00902ce449f4 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Nodes/JsonObject.cs @@ -267,14 +267,14 @@ internal void SetItem(string propertyName, JsonNode? value) OrderedDictionary dict = Dictionary; if ( -#if NET10_0_OR_GREATER - !dict.TryAdd(propertyName, value, out int index) -#else +#if NET9_0 !dict.TryAdd(propertyName, value) +#else + !dict.TryAdd(propertyName, value, out int index) #endif ) { -#if !NET10_0_OR_GREATER +#if NET9_0 int index = dict.IndexOf(propertyName); #endif Debug.Assert(index >= 0);