如何显示新的列表项? [英] How to display new List item?

查看:166
本文介绍了如何显示新的列表项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

next 2 Mp3的名单上,有人可以帮我这个吗?

next 2 Mp3's on the list, can someone help me with this?

推荐答案

您可以使用Console.ReadKey并再次循环遍历列表,并从您最初停止的索引开始。 / p>

You could use the Console.ReadKey and loop through the list again and start from the index where you left off initially.

for (int i = maxCount; i < Mp3spelers.Count(); i++)
        {
            Console.WriteLine(Mp3spelers[i].ID);
            Console.WriteLine(Mp3spelers[i].make);
            Console.WriteLine(Mp3spelers[i].mbsize);
            Console.WriteLine(Mp3spelers[i].model);
            Console.WriteLine(Mp3spelers[i].price);
            Console.WriteLine(Mp3spelers[i].voorraad);
        }

您也可以使其成为一个独立的方法,在代码中循环浏览您的列表,您可以轻松修改要打印的项目数量和从开始打印的索引。

You could also make it a seperate method so you'll only have one place in your code to loop through your list and you can easily modify how many items you want to print and from what index to start printing.

    public void ShowItemsInConsole(int firstIndex, int lastIndex)
    {
        for (int i = firstIndex; i < lastIndex && i < Mp3spelers.Count(); i++)
        {
            Console.WriteLine(Mp3spelers[i].ID);
            Console.WriteLine(Mp3spelers[i].make);
            Console.WriteLine(Mp3spelers[i].mbsize);
            Console.WriteLine(Mp3spelers[i].model);
            Console.WriteLine(Mp3spelers[i].price);
            Console.WriteLine(Mp3spelers[i].voorraad);
        }
    }

这篇关于如何显示新的列表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆