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. what we write

what we write

Scheduled Pinned Locked Moved C#
csharp
4 Posts 4 Posters 6 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.
  • P Offline
    P Offline
    Parshant Verma
    wrote on last edited by
    #1

    Hi what we write in c# int a; int *p=&a;

    G J J 3 Replies Last reply
    0
    • P Parshant Verma

      Hi what we write in c# int a; int *p=&a;

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      You can use pointers in C#, but only in code blocks marked unsafe. Usually you use references. As an int is not a reference type, you have to box it as an object to get a reference to it: int a = 42; object r = a; To get the integer value back from the object, you cast it: int b = (int)r; Note that boxing is much less efficient than working with the plain value types directly, as an object has to be created to contain the value.

      --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • P Parshant Verma

        Hi what we write in c# int a; int *p=&a;

        J Offline
        J Offline
        Just me at will_george something
        wrote on last edited by
        #3

        int a; int *p=&a Not sure. But think it is unsafe code, As I remember it worked in the old Bell Labs 'C'. Sorry, I just had to.. No hate here.. Just sort of 'funnin' ya!:-D

        1 Reply Last reply
        0
        • P Parshant Verma

          Hi what we write in c# int a; int *p=&a;

          J Offline
          J Offline
          Judah Gabriel Himango
          wrote on last edited by
          #4

          unsafe
          {
          int a;
          int *p = &a;
          }

          Compile with /unsafe

          Tech, life, family, faith: Give me a visit. I'm currently blogging about: For Christians: The Significance of Yom Teruah The apostle Paul, modernly speaking: Epistles of Paul Judah Himango

          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