vendredi 10 février 2023

How to access internal field 'NewLineConst' of System.Environment class (System.Private.CoreLib.dll) in .NET 7

I want to access the following field using reflection:

Class is part of:

System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e

enter image description here

I tried the following (amongst others), but the result is null:

 var fld = typeof(Environment).GetField("NewLineConst", BindingFlags.NonPublic | BindingFlags.Instance); // => null

How can I access this internal const field which is part of the partial Enviroment class?





Aucun commentaire:

Enregistrer un commentaire