根据索引获取数组项 [英] Get array item based on index

查看:140
本文介绍了根据索引获取数组项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据我拥有的索引从char数组中获取一个项目。我之前使用过代码来获取指定项的索引但现在我想要相反的方法来获取指定索引的项。我尝试了一些但却无法正常工作。

I am trying to get an item from a char array based on the index that I have. I have used code earlier to get the index of a specified item but now I want the opposite, to get the item of the specified index. I have tried a few things but can't get it working.

我想这样的事情:

char arrayChar = Array.GetItem(index [i]) // I know this isn't right but just so you get the idea.

非常感谢!

推荐答案

假设您的char数组被称为 ArrayOfChars ,索引是 i 。它应该很简单

Assuming your char array is called ArrayOfChars and the index is i. It should be as simple as

char arrayChar = ArrayOfChars[i];

这篇关于根据索引获取数组项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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