"Jay Balapa" wrote...
Iam trying to do the following-
if(myColumn.DataType==typeof(bool))
{
}
this does not work either Type.GetType("System.Boolean")
instead of typeof(bool).
I get the error "Operator == cannot be applied to operands
type and object and bool."
Both ways "should" work, or at least not give that error.
Or you're talking about another type of DataColumn than an instance of
System.Data.DataColumn...
I believe the error must lie somewhere else in your code.
Could you provide a short code snippet that in your meaning "should"
compile, but doesn't?
This compiles and runs fine:
using System;
using System.Data;
class DataColumnTest
{
static void Main(string[] args)
{
DataColumn myColumn = new DataColumn();
myColumn.DataType = typeof(string);
if(myColumn.DataType == typeof(bool))
{
Console.WriteLine(true);
}
else
{
Console.WriteLine(false);
}
}
}
/// Bjorn A