一个代表地址信息的字符串,要把它切分成 省、 市、 县独立显示, 有些地址没有分省或市或县的,只显示有得信息,如“香港特别行政区”,就多不显示
解决方案 »
- 求解未将对象引用设置到对象的实例!!
- c# exe 和dll路径不同,但引用了相同的dll
- VS 2008 开发的winform 应用程序输入法问题
- 用URL访问接口,怎么做
- SqlConnection、SqlCommand、SqlDataReader这一系列不太好用啊
- 怎么实现数据的增删和修改。
- C#开发称重系统,如何通过串口读取电子磅的数据?
- 不用ASP,用C#可否开发,跨互连网的类似于桌面程序的程序
- 加解密模型如何在WEB SERVICE中实现
- sql语句请教 select count(*) from TB_News where IsDelete=1 and NewsTitle like '%108%'
- DataGrid嵌套,在内层DataGrid事件内,如何获取上次DataGrid的行号
- 面试官问的一个问题........,不会
str = textBox1.Text.Trim();
int leng= str.Length;
int local = str.IndexOf('省');
if (local >= 0)
{
str1 = str.Substring(0, local);
if (str.IndexOf('市') >= 0)
{
str2 = str.Substring(str.IndexOf('省') + 1, str.IndexOf('市')-str.IndexOf('省')-1);
if (str.IndexOf('县') >= 0)
{
str3 = str.Substring(str.IndexOf('市') + 1, str.IndexOf('县') - str.IndexOf('市')-1);
}
}
}
else if (str.IndexOf('市') >= 0 && str.IndexOf('省')==-1)
{
str2 = str.Substring(0, str.IndexOf('市'));
if (str.IndexOf('县') >= 0)
{
str3 = str.Substring(str.IndexOf('市') + 1, str.IndexOf('县') - str.IndexOf('市')-1);
}
}
else if (str.IndexOf('县') >= 0 && str.IndexOf('市') ==-1 && str.IndexOf('省') ==-1)
{
str3 = str.Substring(0, str.IndexOf('县'));
}