Based on the question, if input is 1 then output will be
true
otherwise
false
.
static bool ConvertToBoolean(string dataToParse)
{
List<string> booleanList = new List<string> { "1", "0" };
return string.IsNullOrEmpty(dataToParse) ? false : booleanList.Contains(dataToParse);
}
Updated:
static bool ConvertToBoolean(string dataToParse)
{
string trueString = "1";
return string.IsNullOrEmpty(dataToParse) ? false : dataToParse == trueString;
}
Hope it helps.
:)