Files
sharpcompress/src/SharpCompress/Lazy.cs
Adam Hathcock b01e97b168 more clean up
2022-12-20 15:20:49 +00:00

28 lines
457 B
C#

#nullable disable
using System;
namespace SharpCompress;
public class Lazy<T>
{
private readonly Func<T> _lazyFunc;
private bool _evaluated;
private T _value;
public Lazy(Func<T> lazyFunc) => _lazyFunc = lazyFunc;
public T Value
{
get
{
if (!_evaluated)
{
_value = _lazyFunc();
_evaluated = true;
}
return _value;
}
}
}