Best Answer strent, 11 January 2013 - 07:02 AM
Contains isn't available, but the next best thing is IndexOf
Go to the full post  | ||||||||||||||
Trying to use string.Contains
Started by rchelicopter, Jan 11 2013 04:25 AM
Best Answer strent, 11 January 2013 - 07:02 AM
Contains isn't available, but the next best thing is IndexOf Go to the full post
3 replies to this topic
#1Posted 11 January 2013 - 04:25 AM Is there a string.Contains alternative in .netmf. I want to check if a string contains a certain substring
Like
string abc = 1234
if (abc.Contains("1234")) { do stuff } #2Posted 11 January 2013 - 07:02 AM Best Answer Contains isn't available, but the next best thing is IndexOf
#3Posted 11 January 2013 - 07:48 AM Indeed, if IndexOf returns -1, the haystack doesn't include the needle.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs #4Posted 11 January 2013 - 03:41 PM You can always extend the String class (.netmf 4.2 makes this much easier)
public static bool Contains(this String _src, char _search){ for (int i = _src.Length-1; i >= 0; --i) { if (_src.IndexOf(_search) >= 0) { return true; } } return false;}
0 user(s) are reading this topic0 members, 0 guests, 0 anonymous users | ||||||||||||||
|
||||||||||||||
This webpage is licensed under a Creative Commons Attribution-ShareAlike License. | ||||||||||||||