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 using Reference type for pointers

need help in using Reference type for pointers

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 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, I'm using reference types in c# instead of pointers...so in below code i'm sending the ptr which is a pointer but using ref key word now can any one tell me how to increament the pointer *(ptr+i) in c#? 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; }

    C 1 Reply Last reply
    0
    • A Ashraj1982

      Hi, I'm using reference types in c# instead of pointers...so in below code i'm sending the ptr which is a pointer but using ref key word now can any one tell me how to increament the pointer *(ptr+i) in c#? 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; }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      If you pass an int by ref, it's not really a pointer. You can increment the value, but you can't use it as a memory address, at least not easily. Christian Graus - Microsoft MVP - C++

      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