我需要一个从1到x的整数列表,其中x由用户设置.我可以使用for循环构建它,例如假设x是先前设置的整数:
List<int> iList = new List<int>(); for (int i = 1; i <= x; i++) { iList.Add(i); }
这看起来很愚蠢,肯定有一种更优雅的方式来实现这一点,就像PHP范围方法一样
.net c# integer list
.net ×1
c# ×1
integer ×1
list ×1