Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. object?

object?

Scheduled Pinned Locked Moved C#
tutorialquestion
9 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dec82
    wrote on last edited by
    #1

    how to convert any parameter type into object? thanks

    OriginalGriffO M V 3 Replies Last reply
    0
    • D dec82

      how to convert any parameter type into object? thanks

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      In .NET everything is derived from an object - so you can just cast it.

      object o = (object) param;

      Or is that not what you wanted?

      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      M 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        In .NET everything is derived from an object - so you can just cast it.

        object o = (object) param;

        Or is that not what you wanted?

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

        M Offline
        M Offline
        musefan
        wrote on last edited by
        #3

        I don't even think you need to cast it

        Life goes very fast. Tomorrow, today is already yesterday.

        OriginalGriffO 1 Reply Last reply
        0
        • D dec82

          how to convert any parameter type into object? thanks

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          your not by any chance trying to work with automation of some type are you? I remember doing Word automation where they want object as params in functions and you have to set them as object instances outside of the function as they need referencing.

          Life goes very fast. Tomorrow, today is already yesterday.

          M 1 Reply Last reply
          0
          • M musefan

            your not by any chance trying to work with automation of some type are you? I remember doing Word automation where they want object as params in functions and you have to set them as object instances outside of the function as they need referencing.

            Life goes very fast. Tomorrow, today is already yesterday.

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            Variant, I know he wants a variant, I can't beleive linq has brought back the variant (var) X|

            Never underestimate the power of human stupidity RAH

            R 1 Reply Last reply
            0
            • M musefan

              I don't even think you need to cast it

              Life goes very fast. Tomorrow, today is already yesterday.

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              You are right, you can use the implicit cast, but I don't think that is the question he meant to ask. Hopefully, by answering the question he did ask too explicitly, it will prompt him to ask the question in better english... (Did that make sense?)

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              M 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                You are right, you can use the implicit cast, but I don't think that is the question he meant to ask. Hopefully, by answering the question he did ask too explicitly, it will prompt him to ask the question in better english... (Did that make sense?)

                No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                M Offline
                M Offline
                musefan
                wrote on last edited by
                #7

                ;) I think so

                Life goes very fast. Tomorrow, today is already yesterday.

                1 Reply Last reply
                0
                • M Mycroft Holmes

                  Variant, I know he wants a variant, I can't beleive linq has brought back the variant (var) X|

                  Never underestimate the power of human stupidity RAH

                  R Offline
                  R Offline
                  riced
                  wrote on last edited by
                  #8

                  It hasn't. Although that's what I first thought when I came across var. :) When you do var x = from..., x is strongly typed (you may not know what its type is, but, whatever it is, you can't assign something of a different type to it unlike variants.)

                  Regards David R --------------------------------------------------------------- "Every program eventually becomes rococo, and then rubble." - Alan Perlis

                  1 Reply Last reply
                  0
                  • D dec82

                    how to convert any parameter type into object? thanks

                    V Offline
                    V Offline
                    Vasudevan Deepak Kumar
                    wrote on last edited by
                    #9

                    Wouldn't the MSDN or related definition for Boxing help out? http://www.csharphelp.com/archives/archive100.html[^]

                    Vasudevan Deepak Kumar Personal Homepage
                    Tech Gossips
                    The woods are lovely, dark and deep, But I have promises to keep, And miles to go before I sleep, And miles to go before I sleep!

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups