如何检查给定字符串的字符条件 [英] how to check the condition for characters for a given string

查看:57
本文介绍了如何检查给定字符串的字符条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我喜欢使用asp.net和c#.net





hi iam using asp.net with c#.net


Label6.Text = listofboxes[1].boxName;
           Label6.Text += Environment.NewLine + listofboxes[1].packode;
           Label6.Text += Environment.NewLine + listofboxes[1].Status;





iam有字符串,我必须在逗号后选择字符,如下所示

从上面的代码中获取此值。

E12 EE731330947CN ,Avizo

D9 EE688798805CN,已过期





并基于此我有显示背景颜色为标签

你能给出帮助我的例子吗。



iam having string from which i have to select the characters after comma as shown below
iam getting this values from the above code.
E12 EE731330947CN, Avizo
D9 EE688798805CN, Expired


and based on this i to have display background colours for the labels
can you give examples which helps me.

推荐答案

我认为你想要做的就是把字符串分解成'' s组成部分:

I assume that what you want to do is break the string into it''s component parts:
E12 EE731330947CN, Avizo

成为

Becomes

Box.boxName E12
Box.packode EE731330947CN
Box.Status  Avizo



如果是这样,那么它很简单:


If so, then it''s pretty easy:

string inp = "E12 EE731330947CN, Avizo";
string[] parts = inp.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length == 3)
    {
    string Box = parts[0];
    string PackCode = parts[1];
    string Status = parts[2];
    }


这篇关于如何检查给定字符串的字符条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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