如何从字符串中切出特定的部分? [英] How to cut a particular part from a string?

查看:119
本文介绍了如何从字符串中切出特定的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

在我的程序中,我想要一个datagrid单元格值.但我得到了该行的孔值.所以我需要如何在wpf中获取datagrid特定单元格值的帮助.不幸的是我没有得到帮助.

现在我得到了输出,

hi friends,

In my program i want a datagrid cell value,. but i got the hole value of the row,. so i need help for how to get datagrid particular cell value in wpf ?. unfortunately i didnt get help.

now i got the output,

{ name = tuutusdydfh, code = cs11 }



但我只想要,



but i want only ,

cs11



在另一件事中,我准备剪切输出字符串.,请帮助..



In alternate thing i ready to cut the output string., pls help,.

推荐答案

string code = "";

string myString = "{ name = tuutusdydfh, code = cs11 }";
myString = myString.Replace("{", "").Replace("}", "").Replace(" ", "");

string[] parts = myString.Split(',');
foreach(string part in parts)
{
    if (part.StartsWith("code="))
    {
        code = part.Replace("code=", "");
        break;
    }
}



此时,code应该等于"cs11".



At this point, code should be equal to "cs11".


与其从字符串中解析出单元格值,不如尝试通过
Rather than parsing cell value out of a string, try to get the cell value directly as discussed here[^].


这篇关于如何从字符串中切出特定的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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