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. How to deal with reference variable in C#?

How to deal with reference variable in C#?

Scheduled Pinned Locked Moved C#
helpcsharpcomtutorialquestion
9 Posts 5 Posters 0 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.
  • R Offline
    R Offline
    Ron S
    wrote on last edited by
    #1

    Hello, I have created a DLL for COM using VB 6.0. the fucntion has a reference variable which returns some value back. I am accessing this fuction in C# when i am passing the ref variable it is giving me an error. Please help. Thanks in Advance.

    Bharath.S Ron

    S 1 Reply Last reply
    0
    • R Ron S

      Hello, I have created a DLL for COM using VB 6.0. the fucntion has a reference variable which returns some value back. I am accessing this fuction in C# when i am passing the ref variable it is giving me an error. Please help. Thanks in Advance.

      Bharath.S Ron

      S Offline
      S Offline
      Sathesh Sakthivel
      wrote on last edited by
      #2

      bharath.s.r wrote:

      I am accessing this fuction in C# when i am passing the ref variable it is giving me an error.

      What error?

      Regards, Satips.:rose:

      R 1 Reply Last reply
      0
      • S Sathesh Sakthivel

        bharath.s.r wrote:

        I am accessing this fuction in C# when i am passing the ref variable it is giving me an error.

        What error?

        Regards, Satips.:rose:

        R Offline
        R Offline
        Ron S
        wrote on last edited by
        #3

        i am passing a variable as (ref var) error :- ref object is not declared. Thanks in Advance.

        Bharath.S Ron

        K 1 Reply Last reply
        0
        • R Ron S

          i am passing a variable as (ref var) error :- ref object is not declared. Thanks in Advance.

          Bharath.S Ron

          K Offline
          K Offline
          KKrista
          wrote on last edited by
          #4

          Reference variables are surely supported in C#. I think the problem under this case might be the use of variable without declaration.

          Regards, Murali

          R 1 Reply Last reply
          0
          • K KKrista

            Reference variables are surely supported in C#. I think the problem under this case might be the use of variable without declaration.

            Regards, Murali

            R Offline
            R Offline
            Ron S
            wrote on last edited by
            #5

            can u please explain me how i have to rectify it. i Have learn't C# on my own, i was working on VB Before now has been shifted to C#. Thanks in Advance.

            bharath.s

            K 1 Reply Last reply
            0
            • R Ron S

              can u please explain me how i have to rectify it. i Have learn't C# on my own, i was working on VB Before now has been shifted to C#. Thanks in Advance.

              bharath.s

              K Offline
              K Offline
              KKrista
              wrote on last edited by
              #6

              While calling the method, pass the 'reference' variables as SomeMethod(ref varInput); Then in the definition of the Method u have to use the same reference variable as, public void SomeMethod(ref varInput) { //Give ur implementation here. }

              Regards, Murali

              R 1 Reply Last reply
              0
              • K KKrista

                While calling the method, pass the 'reference' variables as SomeMethod(ref varInput); Then in the definition of the Method u have to use the same reference variable as, public void SomeMethod(ref varInput) { //Give ur implementation here. }

                Regards, Murali

                R Offline
                R Offline
                Ron S
                wrote on last edited by
                #7

                the method has allready being deployed in vb6.o in vb 6.0:- public function somefunc(ref variable as string) variable = "XYZ" end function in C# i have given reference to this class and function and created a Runtime callable wrapper. IN c# object.somefunc(ref csharpvar)

                bharath.s

                J J 2 Replies Last reply
                0
                • R Ron S

                  the method has allready being deployed in vb6.o in vb 6.0:- public function somefunc(ref variable as string) variable = "XYZ" end function in C# i have given reference to this class and function and created a Runtime callable wrapper. IN c# object.somefunc(ref csharpvar)

                  bharath.s

                  J Offline
                  J Offline
                  jayart
                  wrote on last edited by
                  #8

                  Make sure you are using the correct namespace.

                  1 Reply Last reply
                  0
                  • R Ron S

                    the method has allready being deployed in vb6.o in vb 6.0:- public function somefunc(ref variable as string) variable = "XYZ" end function in C# i have given reference to this class and function and created a Runtime callable wrapper. IN c# object.somefunc(ref csharpvar)

                    bharath.s

                    J Offline
                    J Offline
                    jimpalmer
                    wrote on last edited by
                    #9

                    maybe this? IN c# string csharpvar; //var must be declared first object.somefunc(ref csharpvar)

                    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