如何使用多维数组 [英] How to use a multi-dimensional array

查看:64
本文介绍了如何使用多维数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上看过,但似乎无法找到我想要的信息。这是我正在尝试做的事情。


我使用split函数创建一个字符串部分数组,例如

I have looked online, but I don''t seem to be able to find the information that I''m wanting. Here is what I''m trying to do.

I have used the split function to create an array of parts of a string such as

展开 | 选择 | Wrap | 行号

推荐答案

Seth,

我很确定你想要什么;但是,您是否会为要跟踪的数据提供一些字符串?
Seth,
I''m fairly certain of what you want; however, would you provide a few strings with the data you want tracked?


您已经使用Split()函数获得了一个字符串数组和子字符串。您现在可以实际使用2个并行数组来存储字符串中子字符串的位置以及主要字符串长度,如下所示:
You already have an Array of Strings and Sub-Strings using the Split() Function. You can now actually use 2 Parallel Arrays to store the Locations of the Sub-Strings within the Strings as well as the Major String Lengths as follows:
展开 | 选择 | 换行 | 行号


Seth,


您的帖子中缺少任何示例字符串数据会让您很难提供帮助。你会发现很难跟随任何事情,因为它没有你的背景(没有为你提供一大堆示例数据,并希望你遵循所说的 - 我希望你欣赏'不是关于事情的方法。


通常情况下,Split()非常适合创建数组,但不适用于多维数组。也就是说,如果您正在处理数据,那么内循环的每次迭代都可以从外部数组中的数据创建一个新数组。


显然,如果数据是最初存储在一个字符串中,那么内部和外部分隔符必须是不同的字符串(当然每个字符串通常都是一个字符)。
Seth,

The absence from your post of any example string data makes this very difficult to help with. You''d find it difficult to follow anything said as it has no context for you (without providing a whole bunch of example data for you and hoping you follow what''s being said - I hope you appreciate that''s not the way to go about things).

Just generally then, Split() is great for creating an array, but doesn''t work well with multi-dimensional arrays. That said, if you''re processing through the data then each iteration of the inner loop can create a new array from the data within an outer array.

Obviously, if the data is originally stored in a string, then the inner and outer separators must be different character strings (generally a single character for each of course).


这篇关于如何使用多维数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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