[Solved] Which statement is more efficient?


try

var firstChar = dr["Value"].ToString()[0];
var ok = firstChar == 'y' || firstChar="Y";

and make some performance-tests – but I don’t think that this will really be a issue at all.

PS: assuming that the string is not empty – if this might be an issue make it

var value = dr["Value"].ToStrin();
var firstChar = String.IsNullOrEmpty(value) ? 'n' : value[0];
var ok = firstChar == 'y' || firstChar="Y";

solved Which statement is more efficient?