I have a string “EMP1$0,EMP2$1,EMP3 $1, Emp4$ 0, emp44$1”; these are employee codes separated by coma (,). Each employee code is appended with their statuses (i.e. 1 for active and 0 for inactive and separated with $ sign). Employee code will not contain spaces, but space can be possible between employee code and $. I need to check if an employee code say “EMP4” is present in this string. Which will be best approach?
Any help is highly appreciable.
Edit:
var strResult = from string str in hdnEmpCodes.Value.Split(',')
where str.Length > 0 && str.Substring(0, str.IndexOf("$")).Trim() == lnkEmpCode.Text.Trim()
select str.ToString();
But it is not giving the desired output.
If you start with the following:
Then you can perform this query to extract the “EMP” codes:
This would give the following result:
It would now be a simple matter of checking if any of the returned values match.
Does this do what you need?