Преобразование / приведение списка<string> в список<ulong>
Я пытался бросить List<string>
собственность на List<ulong>
имущество. Кажется, что бы я ни делал, мне не удается получить или установить данные.
public List<string> _DocumentIds { get; set; } = new List<string>();
Вещи, которые я пытался преобразовать List<string>
в List<ulong>
:
Использование ConvertAll
public List<ulong> DocumentIds
{
get => _DocumentIds.ConvertAll(x => UInt64.Parse(x));
set => _DocumentIds = value.ConvertAll(x => $"{x}");
}
Использование приведения
public List<ulong> DocumentIds
{
get => _DocumentIds.Cast<ulong>().ToList();
set => _DocumentIds = value.Cast<string>().ToList();
}
Использование Select
public List<ulong> DocumentIds
{
get => _DocumentIds.Select(x => UInt64.Parse(x)).ToList();
set => _ = value.Select(x => $"{x}").ToList();
}
То, чем я не горжусь
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();
}
Я использовал точки останова в операторах get set, и он всегда нажимал get дважды, но никогда не нажимал set.