I'm having trouble initializing properties within a class using the method described in this documentation.
Sample:
public class MyClass
{
private Lazy<string> _lazyString;
public MyClass()
{
_lazyString = new Lazy<string>(() => "hello world");
}
public string MyString => _lazyString.Value;
}
When I debug I can see that _lazyString has its boolean IsCreated set to true before I've even accessed the MyString property. Has something changed in the recent c# iterations?
My target framework is netcoreapp3.1
IsCreatedproperty in code without looking at the property it's being used in.Lazy.IsValueCreated(see learn.microsoft.com/en-us/dotnet/api/…) to check if the value for theLazyobject has been created.