求高手!

woailihuan2 2011-11-17 09:21:41
给位大侠!怎样用C#语言编写用泛型储存10以下的数字,然后再循环输出?
...全文
104 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
铜臂阿铁木 2011-11-18
  • 打赏
  • 举报
回复

string numbers = "0123456789";
List<int> list = new List<int>();
foreach(char c in numbers)
{
list.Add((int)(c-48));
}

foreach(int i in list)
{
Console.WriteLine(i+"");
}


or

string numbers = "0123456789";
List<char> list = new List<char>();
foreach(char c in numbers)
{
list.Add(c);
}

foreach(char c in list)
{
Console.WriteLine(c.ToString());
}



我是来捣乱的
threenewbee 2011-11-18
  • 打赏
  • 举报
回复
10以下的数字包括浮点、负数么?

List<double> nums = new List<double>()
{ 2.3, 3.6, 11.0, 0.54, 7.0 -23, -17.5, -1.234, 0, 17.2, 35.0, 100.0, 9.3, 10.0 };
var result = nums.Where(x => x < 10.0).ToList();
foreach (double d in result)
{
Console.WriteLine(d);
}
Lxpd 2011-11-18
  • 打赏
  • 举报
回复
10以 下不重复的数定吗

先定义一个函数,
然后判断参数是否小于10 如果小于10 再判断 集合中是否添加了这个数,如果没添加就加入集合
abutwang 2011-11-18
  • 打赏
  • 举报
回复
10以下的数字就指1-10整数?
stonespace 2011-11-18
  • 打赏
  • 举报
回复
LinkedList<int> lst=new LinkedList<int>();

for(int i=0;i<10;i++)
{
lst.AddLast(i);
}

foreach(int nData in lst)
{
Console.WriteLine(nData.ToString());

}
暖枫无敌 2011-11-17
  • 打赏
  • 举报
回复

List<int> number = new List<int>();
number.Add(0);
number.Add(1);
number.Add(2);
number.Add(3);
number.Add(4);
number.Add(5);
number.Add(6);
number.Add(7);
number.Add(8);
number.Add(9);
foreach(int i in number)
{
Response.Write(i+"</br>");
}
woailihuan2 2011-11-17
  • 打赏
  • 举报
回复
请各位大侠写清楚一点!小弟刚入门!

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧