开发者

In silverlight how do you scrub a string

开发者 https://www.devze.com 2023-01-03 02:44 出处:网络
I have a 开发者_运维技巧string that looks like this \" Into\" and I can\'t figure out what the \" \" value is just before the Into.It\'s not a space, it\'s not an enter.At least i don\'t think so.I\'v

I have a 开发者_运维技巧string that looks like this " Into" and I can't figure out what the " " value is just before the Into. It's not a space, it's not an enter. At least i don't think so. I've tried doing a replace to get rid of it..

So now i'm just trying to figure out what that character value is. Convert.int32 doesn't get it done... What can i use to get rid of that character... I guess i could write a function that would loop through the alphabet and do it that way.. but figured there was a better way.

thanks shannon


Have you tried using Trim() which removes all leading and trailing whitespace from a string?

e.g. (C#)

string cleanString = dirtyString.Trim();

To find the ASCII val of the "mystery" character:

int charVal = (int)dirty.ToCharArray()[0];

P.S. Wouldn't it be more appropriate to ask about using C# or .NET to scrub a string?

EDIT

// algorithm for removing weird char from string

    string dirtyString = " sdfsf ";

    // get the offending character:
    char dirtyChar = dirtyString.ToCharArray()[0];

    // replace offending character with something known like an asterisk
    string cleanString = dirtyString.Replace(dirtyChar, '*');

    // remove asterisk from string
    cleanString = cleanString.Replace("*", "");
0

精彩评论

暂无评论...
验证码 换一张
取 消