I've been trying to cast List<string> property to List<ulong> property. It seems no matter what I do, it keeps failing to get or set data.
public List<string> _DocumentIds { get; set; } = new List<string>();
Things I've tried to convert List<string> to List<ulong>:
Using ConvertAll
public List<ulong> DocumentIds
{
get => _DocumentIds.ConvertAll(x => UInt64.Parse(x));
set => _DocumentIds = value.ConvertAll(x => $"{x}");
}
Using Casts
public List<ulong> DocumentIds
{
get => _DocumentIds.Cast<ulong>().ToList();
set => _DocumentIds = value.Cast<string>().ToList();
}
Using Select
public List<ulong> DocumentIds
{
get => _DocumentIds.Select(x => UInt64.Parse(x)).ToList();
set => _ = value.Select(x => $"{x}").ToList();
}
Something I'm not proud of
public List<ulong> DocumentIds
{
get
{
var Values = new List<ulong>();
foreach (var Value in _DocumentIds) Values.Add(UInt64.Parse(Value));
return Values;
}
set => _DocumentIds = value.Cast<string>().ToList();
}
I've used breakpoints on get set statements and it always hit get twice but never hits set.