Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataRow to bool casting

I have an xml file from which I read data in the unit test : [DataSource] For the xml line : <DataBool>true</DataBool>, I try to read value by :

bool bData = (bool)TestContext.DataRow[4];

But it throws exception - invalid casting.What is the possible efficient solution?

like image 764
Yakov Avatar asked Apr 28 '26 03:04

Yakov


1 Answers

If there's no schema associated with it, then it's probably just a string. If so, use bool.Parse or bool.TryParse to convert it from a string to a bool.

like image 94
Kyle W Avatar answered May 03 '26 18:05

Kyle W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!