QuinnDester
asked on
!string.IsNullOrEmpty c# Problem VS2010
In the code below i am trying to check that the string does not contain "" before processing.
some how this is still processing the string when it contains ""
the data is picked up from a comma delimited array, with blank ,,,,,, where there is no data, how can i stop the processing of stirngs that contain no data
Thank you
some how this is still processing the string when it contains ""
the data is picked up from a comma delimited array, with blank ,,,,,, where there is no data, how can i stop the processing of stirngs that contain no data
Thank you
if (!string.IsNullOrEmpty(Charon))
{
shipsRetrieved = shipsRetrieved + Charon + "<br />".ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Make a copy of the string, then remove all commas. Now test if this string is empty. (Remember to do this on a copy because it will trash the real line)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the string is "" no commas in it, the data is collected from a comma delimted array, the ,,,,,, are just delimitations as place holders so the correct data is alway in the right place in the array.
i only mentioned this so you know how the data is picked up, incase that has a bearing on what is held in the string.
i only mentioned this so you know how the data is picked up, incase that has a bearing on what is held in the string.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"" is an empty string. As Divinity says that should be trapped and not processed.
Please paste your complete code - you might be missing something else and thinking the failure is with this bit of code.
Please paste your complete code - you might be missing something else and thinking the failure is with this bit of code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My mistake, i was checking for an empty string after adding additional text to the string, so they were never empty...
moving the check to earltier in the code sorted it out.
moving the check to earltier in the code sorted it out.