How to find right namespace?

  • Thread starter Thread starter Shaw
  • Start date Start date
S

Shaw

I try to convert a String obj to int and decimal number
by using ToInt32 and ToDecimal methods. But, compiler
keeps saying "The name 'ToInt32' does not exist in the
class or namespace".

I think, I don't include the right namespace in
the "using" statement, such as "using
System.Collections;". I have hard time to find right
namespace which the ToInt32 and ToDecimal bellow to.

How can I find right namespace quickly? Anyone has idea?
Thanks.

Shaw
 
Shaw said:
I try to convert a String obj to int and decimal number
by using ToInt32 and ToDecimal methods. But, compiler
keeps saying "The name 'ToInt32' does not exist in the
class or namespace".

I think, I don't include the right namespace in
the "using" statement, such as "using
System.Collections;". I have hard time to find right
namespace which the ToInt32 and ToDecimal bellow to.

How can I find right namespace quickly? Anyone has idea?
Thanks.

Methods don't belong to namespaces, they belong to classes. In this
case, it's the Convert class. You need to use something like:

int i = Convert.ToInt32(s);
 
Back
Top