在数组中查找第n个元素的逻辑

编程入门 行业动态 更新时间:2024-10-19 08:50:41
本文介绍了在数组中查找第n个元素的逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在数组中找到第n个元素的逻辑

logic to find nth element in an array

推荐答案

下一次,请更具体地回答您的问题... 这是在c中使用数组的一些示例 Next time be more specific with your question... here are some example to use array in c # string[] mystringarray=new string[2]; mystring[0]=new string[2]; mystring[1]="2nd element of first diminution"; mystring[0][0]="first element of first dimension"; mystring[0][1]="2nd element of first dimension"; //finding nth element, eg nth= 0,0 Console.WriteLine(mystring[0][0]);

这是一个链接,它将为您提供教程 msdn.microsoft/en-us/library/aa288453 (v = vs.71).aspx [ ^ ]

here is a link, it will give you a tutorial msdn.microsoft/en-us/library/aa288453(v=vs.71).aspx[^]

这个问题"几乎是胡言乱语:n-某些数组的元素是array[n]. 但是,有一个陷阱:.NET允许创建不基于0的数组,即使此功能被称为不符合CLS.例如,对于多维数组,可以使用以下System.Array.CreateInstance方法完成此操作: This "problem" is nearly the poor gibberish: n-the element of some array is array[n]. However, there is a catch: .NET allows to create arrays which are not 0-based, even though this feature is dubbed not CLS-compliant. For example, for a mutidimensional array, it can be done using this System.Array.CreateInstance method: public static Array CreateInstance( Type elementType, int[] lengths, int[] lowerBounds )

请参阅: msdn.microsoft/en-us/library/x836773a.aspx [ ^ ]; 其他可能性,请参见: msdn.microsoft/en-us/library/system.array.aspx [ ^ ]. 那么如何索引这样的数组呢?自然地,在索引适当移动的情况下,根据每个维度的下限值,可以使用以下方法: msdn.microsoft/en-us/library/system.array. getlowerbound.aspx [ ^ ]. 我在上面引用的第一个MSDN帮助页面中显示的代码示例中对此进行了说明.

—SA

Please see: msdn.microsoft/en-us/library/x836773a.aspx[^]; for other possibilities, please see: msdn.microsoft/en-us/library/system.array.aspx[^]. How to index such arrays then? Naturally, with appropriate shift in the index, according to the value of lower bound in each dimension, using this method: msdn.microsoft/en-us/library/system.array.getlowerbound.aspx[^]. This is illustrated in the code sample shown in the very first MSDN help page I referenced above.

—SA

更多推荐

在数组中查找第n个元素的逻辑

本文发布于:2023-11-30 04:32:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648737.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组中   逻辑   元素

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!