如何在C#中将数字与字符串分开? [英] how could I disjoin number from string in C#?

查看:373
本文介绍了如何在C#中将数字与字符串分开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将这样的一些数据保存到我的数据库中:"75到150".
我需要其中的数字进行比较和计算.无法更改此字符串以保存在数据库中.

I have to save some data like this to my database:" 75 to 150".
and I need the numbers in it for comparing and calculating. there is no way to change this string for saving in database. how could I disjoin this numbers from string and use them?

推荐答案

使用方法:

Use:

string[] str = ("75 to 150").Split(new char[]{'' ''});
int[], LoHi = new int[]{int.Parse(str[0]),int.Parse(str[2])};


这篇关于如何在C#中将数字与字符串分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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