pointers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J. Marcelo Barbieri

    #1

    pointers

    Can I use pointer in C# the same way I used to do in C++?



  • Marcelo

    #2
    Re: pointers

    yes, but you must keep in mind that you need to mark you code as unsafe. To
    do so...

    right click your project, properties, configuration properties and set to
    true the line "Allow unsafe code blocks".

    Then, in your function, declare (example):

    private unsafe void soma(int a, int b, int* c)
    {
    *c = a+b;
    }

    As far as I can remember, this is how it's done. I have no code of pointers
    here... Be sure to check the restrictions that may apply to using
    pointers...

    I thought that BF used to teach this kind of stuff...

    "J. Marcelo Barbieri" <mbarbieri@bf.c om.br> wrote in message
    news:uJkh8AsVDH A.1620@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Can I use pointer in C# the same way I used to do in C++?
    >
    >
    >[/color]


    Comment

    • Christian

      #3
      Re: pointers

      And remember that it's not recommended...
      Christian

      "Marcelo" <sms2k@hotmail. com> ha scritto nel messaggio
      news:ODTGhHsVDH A.2344@TK2MSFTN GP09.phx.gbl...[color=blue]
      > yes, but you must keep in mind that you need to mark you code as unsafe.[/color]
      To[color=blue]
      > do so...
      >
      > right click your project, properties, configuration properties and set to
      > true the line "Allow unsafe code blocks".
      >
      > Then, in your function, declare (example):
      >
      > private unsafe void soma(int a, int b, int* c)
      > {
      > *c = a+b;
      > }
      >
      > As far as I can remember, this is how it's done. I have no code of[/color]
      pointers[color=blue]
      > here... Be sure to check the restrictions that may apply to using
      > pointers...
      >
      > I thought that BF used to teach this kind of stuff...
      >
      > "J. Marcelo Barbieri" <mbarbieri@bf.c om.br> wrote in message
      > news:uJkh8AsVDH A.1620@TK2MSFTN GP12.phx.gbl...[color=green]
      > > Can I use pointer in C# the same way I used to do in C++?
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...