输入一个数字并检查它是否在数组中 [英] enter a number and check if it is in the array or not in c sharp

查看:122
本文介绍了输入一个数字并检查它是否在数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入数字并检查它是否在数组中

enter a number and check if it is in the array or not

推荐答案

如果您不想编写自己的Find(Keith's已经向您展示了如何操作),则可以使用内置的查找"功能.参见:

http://msdn.microsoft.com/en-us/library/d9hy2xwa(VS .80).aspx [ ^ ]

该页面上也有一个代码示例,您可以阅读.

您的教授/老师不太可能允许您使用LINQ,但是在大多数现实世界中,人们只会使用Linq来检查数组中的项目.提交作业时,您可能应该在脚注中提到这一点.
If you don''t want to write your own Find (Keith''s already shown you how), you can use the built-in Find functionality. See:

http://msdn.microsoft.com/en-us/library/d9hy2xwa(VS.80).aspx[^]

That page has a code example too that you can go through.

It''s not very likely that your professor/teacher would let you use LINQ, but in most real world apps people would just use Linq to check for an item in an array. You should probably mention this in a footnote when you submit your assignment.


对于书房中的每个项目:
如果该项是值,则返回true
如果您到达数组的末尾,则返回false.
For each item in the arrary:
If the item is the value, return true
If you reach the end of the array, return false.


嗯...是的...问您的教授如何去找一位导师.

这真的是您目前的最佳做法...
um...yeah...ask your professor how to go about getting a tutor.

That''s really your best course of action right now...


这篇关于输入一个数字并检查它是否在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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