在C#windows应用程序中拆分数组 [英] splite the array in C# windows application

查看:60
本文介绍了在C#windows应用程序中拆分数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我有数组值RSSI = -68.2,我只需要68.2

如何在C#windows应用程序中获取此内容





感谢All

Hi All
I have array value "RSSI=-68.2" where I need only 68.2
How can I get this in C# windows application


Thanks to All

推荐答案

这是无论数组元素还是其他什么都没关系其他。唯一重要的是这是对字符串对象的引用。使用 string.Split

http://msdn.microsoft.com/en-us/library/system.string.split.aspx [ ^ ]。



我怀疑你真的需要68.2,更有可能的是,你需要-68.2,所以用分隔符=分开。



-SA
It does not matter if this is array element or anything else. The only important thing is this is a reference to a string object. Use string.Split:
http://msdn.microsoft.com/en-us/library/system.string.split.aspx[^].

I doubt you really need "68.2", more likely, you need "-68.2", so split by the delimiter '='.

—SA


你也可以使用正则表达式来获取你在数组字符串中指定的值



这是一个我可以的例子让你从字符串中获取值。

You can also use Regular Expression to get the value you specified in an array string

Here is an example i can give you to get the value from a string.
Regex r = new Regex(@"[0-9]+\.[0-9]+");
Match m = r.Match(myString);
string value = m.Value;
Console.WriteLine("{0} is a Number",value);





您也可以从以下链接中获取参考资料以进一步了解。

http://www.c-sharpcorner.com/uploadfile/puranindia/regular-expressions -in-C-Sharp / [ ^ ]


这篇关于在C#windows应用程序中拆分数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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