|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Check to see DataColumn DataType is Boolean?Hello,
Iam trying to do the following- if(myColumn.DataType==typeof(bool)) { } I get the error "Operator == cannot be applied to operands type and object and bool." Is there a workaround? Thanks. jay Jay Balapa wrote:
> Hello, Try Type.GetType("System.Boolean") instead of typeof(bool).> > Iam trying to do the following- > > if(myColumn.DataType==typeof(bool)) > { > } > > I get the error "Operator == cannot be applied to operands type and object > and bool." > > Is there a workaround? Hi Hunter,
Error states that I cannot use "==" operator period when comparing Boolean. I have tried what you suggested and it does not work. jay Show quote "Sericinus hunter" <serh***@flash.net> wrote in message news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com... > Jay Balapa wrote: >> Hello, >> >> Iam trying to do the following- >> >> if(myColumn.DataType==typeof(bool)) >> { >> } >> >> I get the error "Operator == cannot be applied to operands type and >> object and bool." >> >> Is there a workaround? > > Try Type.GetType("System.Boolean") instead of typeof(bool). Jay Balapa wrote:
> Hi Hunter, Strange. Works for me with .Net 1.1> > Error states that I cannot use "==" operator period when comparing Boolean. > > I have tried what you suggested and it does not work. > > jay Show quote > "Sericinus hunter" <serh***@flash.net> wrote in message > news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com... >> Jay Balapa wrote: >>> Hello, >>> >>> Iam trying to do the following- >>> >>> if(myColumn.DataType==typeof(bool)) >>> { >>> } >>> >>> I get the error "Operator == cannot be applied to operands type and >>> object and bool." >>> >>> Is there a workaround? >> Try Type.GetType("System.Boolean") instead of typeof(bool). > > Iam using 2.0.
Show quote "Sericinus hunter" <serh***@flash.net> wrote in message news:7c96g.782$zR3.530@newssvr33.news.prodigy.com... > Jay Balapa wrote: >> Hi Hunter, >> >> Error states that I cannot use "==" operator period when comparing >> Boolean. >> >> I have tried what you suggested and it does not work. >> >> jay > > Strange. Works for me with .Net 1.1 > >> "Sericinus hunter" <serh***@flash.net> wrote in message >> news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com... >>> Jay Balapa wrote: >>>> Hello, >>>> >>>> Iam trying to do the following- >>>> >>>> if(myColumn.DataType==typeof(bool)) >>>> { >>>> } >>>> >>>> I get the error "Operator == cannot be applied to operands type and >>>> object and bool." >>>> >>>> Is there a workaround? >>> Try Type.GetType("System.Boolean") instead of typeof(bool). >> Jay,
Can you show the code as you did that, This should in my opinion be the same in 1.x as in 2.0 Cor Show quote "Jay Balapa" <jbal***@hotmail.com> schreef in bericht news:uOpWKpvbGHA.3908@TK2MSFTNGP02.phx.gbl... > Iam using 2.0. > > > "Sericinus hunter" <serh***@flash.net> wrote in message > news:7c96g.782$zR3.530@newssvr33.news.prodigy.com... >> Jay Balapa wrote: >>> Hi Hunter, >>> >>> Error states that I cannot use "==" operator period when comparing >>> Boolean. >>> >>> I have tried what you suggested and it does not work. >>> >>> jay >> >> Strange. Works for me with .Net 1.1 >> >>> "Sericinus hunter" <serh***@flash.net> wrote in message >>> news:TQ86g.779$zR3.413@newssvr33.news.prodigy.com... >>>> Jay Balapa wrote: >>>>> Hello, >>>>> >>>>> Iam trying to do the following- >>>>> >>>>> if(myColumn.DataType==typeof(bool)) >>>>> { >>>>> } >>>>> >>>>> I get the error "Operator == cannot be applied to operands type and >>>>> object and bool." >>>>> >>>>> Is there a workaround? >>>> Try Type.GetType("System.Boolean") instead of typeof(bool). >>> > This works, .NET - FW2.0
DataColumn myColumn = new DataColumn("name",System.Type.GetType("System.Boolean")); if (myColumn.DataType == typeof(bool)) { if (myColumn.DataType == typeof(Boolean)) { xxx = "okay"; } } Show quote "Jay Balapa" <jbal***@hotmail.com> wrote in message news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl... > Hello, > > Iam trying to do the following- > > if(myColumn.DataType==typeof(bool)) > { > } > > I get the error "Operator == cannot be applied to operands type and object > and bool." > > Is there a workaround? > > Thanks. > jay > > > > Hi Jay,
That code should work. What is the myColumn type exactly? -- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Jay Balapa" <jbal***@hotmail.com> wrote in message news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl... > Hello, > > Iam trying to do the following- > > if(myColumn.DataType==typeof(bool)) > { > } > > I get the error "Operator == cannot be applied to operands type and object > and bool." > > Is there a workaround? > > Thanks. > jay > > > > Hi Miha,
Thanks for replying. myColumn is just an iterator for a row. foreach (DataColumn myColumn from myTable.Columns) Thanks. jay Show quote "Miha Markic [MVP C#]" <miha at rthand com> wrote in message news:ugSGME1bGHA.4108@TK2MSFTNGP03.phx.gbl... > Hi Jay, > > That code should work. > What is the myColumn type exactly? > > -- > Miha Markic [MVP C#] > RightHand .NET consulting & development www.rthand.com > Blog: http://cs.rthand.com/blogs/blog_with_righthand/ > > "Jay Balapa" <jbal***@hotmail.com> wrote in message > news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl... >> Hello, >> >> Iam trying to do the following- >> >> if(myColumn.DataType==typeof(bool)) >> { >> } >> >> I get the error "Operator == cannot be applied to operands type and >> object and bool." >> >> Is there a workaround? >> >> Thanks. >> jay >> >> >> >> > > Can you create a simple sample that reproduces the problem?
-- Show quoteMiha Markic [MVP C#] RightHand .NET consulting & development www.rthand.com Blog: http://cs.rthand.com/blogs/blog_with_righthand/ "Jay Balapa" <jbal***@hotmail.com> wrote in message news:e29qFd4bGHA.3348@TK2MSFTNGP03.phx.gbl... > Hi Miha, > > Thanks for replying. > > myColumn is just an iterator for a row. > > foreach (DataColumn myColumn from myTable.Columns) > > Thanks. > jay > > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message > news:ugSGME1bGHA.4108@TK2MSFTNGP03.phx.gbl... >> Hi Jay, >> >> That code should work. >> What is the myColumn type exactly? >> >> -- >> Miha Markic [MVP C#] >> RightHand .NET consulting & development www.rthand.com >> Blog: http://cs.rthand.com/blogs/blog_with_righthand/ >> >> "Jay Balapa" <jbal***@hotmail.com> wrote in message >> news:OdPENEvbGHA.1208@TK2MSFTNGP02.phx.gbl... >>> Hello, >>> >>> Iam trying to do the following- >>> >>> if(myColumn.DataType==typeof(bool)) >>> { >>> } >>> >>> I get the error "Operator == cannot be applied to operands type and >>> object and bool." >>> >>> Is there a workaround? >>> >>> Thanks. >>> jay >>> >>> >>> >>> >> >> > > |
|||||||||||||||||||||||