如何访问元素数组? [英] How to have access to an element array ?

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

问题描述




如何抓住字符串中的特定元素值



让'假设我们有一个完整的字符串字典并且在特定行上

并且需要检索其中一个项目。

我找到了ContainsKey方法但是当我写(在一个foreach循环中):


if(myStringDicArray.ContainsKey(" ControlID"))


it'只是返回真或假!我需要返回特定

元素的值。


提前谢谢

新手

Hi,

How can I grab to a specific element value located into a string dicitionary
?
Let''s say we have an string dictionary which is full and on a specific row
and need to retrieve one of the items.
I found "ContainsKey" method but when I write (within a foreach loop):

if (myStringDicArray.ContainsKey("ControlID"))

it''s just returns true or false! I need to return the value in that specific
element.

Thanks in advance
Newbie

推荐答案

使用索引器:

string val =(string)myStringDicArray [" ControlID"];

HTH;

Eric Cadwell
http://www.origincontrols .com
Use indexers:

string val = (string)myStringDicArray["ControlID"];
HTH;
Eric Cadwell
http://www.origincontrols.com


有时RTFM有帮助:
http://msdn.microsoft.com/library/de...classtopic.asp


在底部你会找到PrintKeysAndValues2函数,它有一个例子

,即myCol [myKeys [i]]" myKeys [i]是你正在寻找的钥匙

for。 => myStringDicArray [" ControlID"]

" C#newbie" <它************** @ yahoo.com> schreef在bericht

新闻:在************* @ tk2msftngp13.phx.gbl ...
Sometimes RTFM helps :
http://msdn.microsoft.com/library/de...classtopic.asp

At the bottom you find the PrintKeysAndValues2 function, it has an example
in it, namely "myCol[myKeys[i]]" where myKeys[i] is the key you''re looking
for. => myStringDicArray["ControlID"]
"C# newbie" <it**************@yahoo.com> schreef in bericht
news:On*************@tk2msftngp13.phx.gbl...


如何获取位于字符串
dicitionary中的特定元素值?
让我们说我们有一个完整的字符串字典并且在特定的行上
和需要检索其中一个项目。
我找到了ContainsKey。方法但是当我写(在foreach循环中):

if(myStringDicArray.ContainsKey(" ControlID"))

它只是返回true或false!我需要在
特定元素中返回值。

提前致谢
新手
Hi,

How can I grab to a specific element value located into a string dicitionary ?
Let''s say we have an string dictionary which is full and on a specific row
and need to retrieve one of the items.
I found "ContainsKey" method but when I write (within a foreach loop):

if (myStringDicArray.ContainsKey("ControlID"))

it''s just returns true or false! I need to return the value in that specific element.

Thanks in advance
Newbie


C#newbie< it ************** @ yahoo.com>写道:
C# newbie <it**************@yahoo.com> wrote:
如何获取位于字符串中的特定元素值
How can I grab to a specific element value located into a string dicitionary
?




请参阅我对您的回复周六同样的问题。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复对于小组,请不要给我发邮件



See my response to your identical question from Saturday.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


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

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