Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem with DataType

Hi,
How to resolve this
Error    4    'string' does not contain a definition for 'DataType' and no extension method 'DataType' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)    C:\App16\Default.aspx.cs    64    24    App16

due to this line?

if (!(str1.DataType==typeof(int)))
            ...

Open in new window

Avatar of Monica P
Monica P
Flag of India image

Are you checking like this ?

int i = 0;
// Prints True for any value of i
Console.WriteLine(i.GetType() == typeof(int));
Avatar of Peter Chan

ASKER

No, I did declare str1 as a string above. How to correct my codes above?
Avatar of kaufmed
What are you trying to do? I don't see the point of comparing a string variable's type to see if it is of type string--it will always be a string. What is your goal here?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial