Results 1 to 2 of 2

Thread: Casting

  1. #1
    Join Date
    Dec 1969

    Default Casting

    I know how to go from:<BR> Object to string<BR> basic type to basic type<BR> basic type to string<BR><BR>I want to know how to go from:<BR> Object to basic type<BR> string to basic type<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Casting

    Object to "basic type":<BR><BR>Object o = ... get an Object from someplace.<BR>myClass instance = (myClass) o;<BR><BR>But this assumes then "o" is *REALLY* an instance of myClass. You&#039;ll get a cast error, otherwise. And this would apply to even types such as int, double, etc.<BR><BR>**********<BR><BR>String to basic type: No guarantee you *can* do that.<BR><BR>If, by Basic Type, you mean int32, int64, double, etc., then look at the corresponding classes Int32, Int64, etc., for the various "Parse" methods.<BR><BR>If you mean your own defined type, then you&#039;ll need to provide a method or constructor that takes a string and understands what the string "means".<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts