Compare strings

Comparing strings in an IF statement

Page 1 of 1

2 Replies - 1900 Views - Last Post: 07 February 2009 - 05:30 AM Rate Topic: -----

#1 Typewriter   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-October 08

Compare strings

Posted 07 February 2009 - 05:06 AM

Hi,

I wanted to know if it is possible to compare strings in an IF statement?

When I try to do it I get an error message saying:
"Operator '==' cannot be applied to operands of type 'method group' and 'method group'.

What does this mean?

The code I'm using is the following:

//Read the extension field from a SQL statement
//The ofd_ext field is information about a file

if ((dr["extension"].ToString) == (ofd_ext.ToString))
{

  label9.Text = "Correct";

}								





Any help would be great.

Thanks in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Compare strings

#2 semaz   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 116
  • Joined: 24-November 08

Re: Compare strings

Posted 07 February 2009 - 05:28 AM

you are missing a brackets after the ToString method

try this code :

if ((dr["extension"].ToString()) == (ofd_ext.ToString()))
{

  label9.Text = "Correct";

}



Was This Post Helpful? 0
  • +
  • -

#3 Typewriter   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 01-October 08

Re: Compare strings

Posted 07 February 2009 - 05:30 AM

Always missing the little things....

Thanks, it works now!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1