数组中的计数的重复号码 [英] Counting repeating numbers in an Array

查看:120
本文介绍了数组中的计数的重复号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相当新的C#。有类要求我们来从用户输入值的数组赋值。这部分是做与工作的完美。

Fairly new to C#. Have an assignment for class that asks us to generate an array from user inputted values. This part is done and work's perfectly.

现在该数组完成我需要能够显示在Console.WriteLine阵列中输入的每个不同的数,多少次这个数字出现,我有点失去了对如何做到这一点。

Now that the array is completed I need to be able to display each distinct number entered in the array in a Console.WriteLine, and how many times that number appeared and I'm a little lost on how to accomplish this.

推荐答案

您可以使用LINQ?如果是这样,调查 GROUPBY 计数()。基本上有一个一行将在这里工作,但因为它的功课我会让你工作的细节留给自己......寻求更多的帮助,当你有一个走不过,如果你遇到的问题。

Are you allow to use LINQ? If so, investigate GroupBy and Count(). Basically there's a one-liner which will work here, but as it's homework I'll let you work out the details for yourself... ask for more help when you've had a go though, if you run into problems.

这篇关于数组中的计数的重复号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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