I have a simple cast issue in following simple c# method
using System;
using System.Data.SqlTypes;
...
private void method1() {
string s = "TestString";
object o = s;
SqlString t1 = (SqlString) s;
SqlString t2 = (SqlString) o;
}
...
When casting directly from s (in case of t1), I don't get any error but when casting from o I get exception:
Specified cast is not valid.
I have same problem converting from object to all types System.Data.SqlTypes
How can I cast an object that has string in it to SqlString?