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. Need help in parameter passing by Reference

Need help in parameter passing by Reference

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
4 Posts 2 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.
  • A Offline
    A Offline
    Ashraj1982
    wrote on last edited by
    #1

    Hi, Can i know how to pass the address of the variable in c#? Following is the code in c which has to be converted into c#.. public int Largest(int *ptr,int Icount) { int largest =0; largest = *(ptr+0); for(int i=0; i < Icount; i++) { if( *(ptr+i) >= largest) { largest = *(ptr + i); } } return largest; } plz let me know how to sent the reference and increament the pointer.

    R 1 Reply Last reply
    0
    • A Ashraj1982

      Hi, Can i know how to pass the address of the variable in c#? Following is the code in c which has to be converted into c#.. public int Largest(int *ptr,int Icount) { int largest =0; largest = *(ptr+0); for(int i=0; i < Icount; i++) { if( *(ptr+i) >= largest) { largest = *(ptr + i); } } return largest; } plz let me know how to sent the reference and increament the pointer.

      R Offline
      R Offline
      rah_sin
      wrote on last edited by
      #2

      you can use ref key word in c# to send the reference of variable public int Largest(ref int ptr,int Icount) { int largest =0; largest = (ptr+0); for(int i=0; i < Icount; i++) { if( (ptr+i) >= largest) { largest = (ptr + i); } } return largest; } rahul -- modified at 5:08 Monday 15th May, 2006

      A 1 Reply Last reply
      0
      • R rah_sin

        you can use ref key word in c# to send the reference of variable public int Largest(ref int ptr,int Icount) { int largest =0; largest = (ptr+0); for(int i=0; i < Icount; i++) { if( (ptr+i) >= largest) { largest = (ptr + i); } } return largest; } rahul -- modified at 5:08 Monday 15th May, 2006

        A Offline
        A Offline
        Ashraj1982
        wrote on last edited by
        #3

        Thanks Rahul... But i'm getting error "Identifier Expected" so any idea....

        R 1 Reply Last reply
        0
        • A Ashraj1982

          Thanks Rahul... But i'm getting error "Identifier Expected" so any idea....

          R Offline
          R Offline
          rah_sin
          wrote on last edited by
          #4

          sorry i forgot to add int after ref key word add it and try rahul

          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