7 Replies - 3680 Views - Last Post: 25 February 2008 - 07:29 AM Rate Topic: -----

#1 skyHigh  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 116
  • Joined: 01-October 07

does C# have pointer?

Post icon  Posted 21 February 2008 - 10:08 AM

I read this whole book, but it didnt mention anything about pointer so does C# have pointer?
Is This A Good Question/Topic? 0
  • +

Replies To: does C# have pointer?

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: does C# have pointer?

Posted 21 February 2008 - 11:20 AM

They do to a limited degree, however they are unsafe and should be avoided.

Pointer types
Was This Post Helpful? 0
  • +
  • -

#3 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5882
  • View blog
  • Posts: 12,760
  • Joined: 16-October 07

Re: does C# have pointer?

Posted 21 February 2008 - 11:52 AM

Yes, but...

The pointer notation is a horrid atrophied addendum that some C programmers snuck in, along with structs. There's no reason to even touch the things, unless you're dealing with unmanaged code and have to talk to some unfriendly DLLs.

That said, the real pointers in C# are hidden. Objects are passed by ref in a pretty much identical way to Java. If you ever felt the need to pass int *p, you do better to use ref int p. Even better, just make a nice class to hand such things about.
Was This Post Helpful? 0
  • +
  • -

#4 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: does C# have pointer?

Posted 21 February 2008 - 02:00 PM

View Postbaavgai, on 21 Feb, 2008 - 01:52 PM, said:

Yes, but...

The pointer notation is a horrid atrophied addendum that some C programmers snuck in, along with structs. There's no reason to even touch the things, unless you're dealing with unmanaged code and have to talk to some unfriendly DLLs.

That said, the real pointers in C# are hidden. Objects are passed by ref in a pretty much identical way to Java. If you ever felt the need to pass int *p, you do better to use ref int p. Even better, just make a nice class to hand such things about.



great point baavgai. but don't forget about delegate which are very useful and are similar to a function point in c and c++
Was This Post Helpful? 0
  • +
  • -

#5 skyHigh  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 116
  • Joined: 01-October 07

Re: does C# have pointer?

Posted 21 February 2008 - 03:38 PM

thank you everyone for the answers. In C++ pointer is important and now C# doesn't depend heavily on it that's cool.. unmanaged code, hmm never heard that term before..
Was This Post Helpful? 0
  • +
  • -

#6 javagoutom  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 114
  • Joined: 20-September 07

Re: does C# have pointer?

Posted 24 February 2008 - 11:35 PM

Yes it is possible to use pointer in c# but the code is unsafe so it is better not to use unsafe code.....
Was This Post Helpful? 0
  • +
  • -

#7 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: does C# have pointer?

Posted 24 February 2008 - 11:41 PM

Quote

unmanaged code, hmm never heard that term before..

You'll come across it a lot while programming in .NET (esp. while writing interop code)
Was This Post Helpful? 0
  • +
  • -

#8 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5882
  • View blog
  • Posts: 12,760
  • Joined: 16-October 07

Re: does C# have pointer?

Posted 25 February 2008 - 07:29 AM

View Postborn2c0de, on 25 Feb, 2008 - 01:41 AM, said:

Quote

unmanaged code, hmm never heard that term before..

You'll come across it a lot while programming in .NET (esp. while writing interop code)


Or, not at all. It depends.

Unmanaged basically means any code that runs outside of the .NET framework. So, lots of DLLs, and COM objects, drivers, etc, are unmanaged. The .NET framework itself wraps a lot of unmanaged code inside managed librarys, but that's technically not the programmers problem. Many of the constructs that are used to talk to external code are considered unmanaged, because you simply don't need to use them otherwise.

If you program something in C# from the ground up and use only the standard assemblies, you'll never have to think managaged or unmanaged code. Even interop code, like talking to an Excel application or something, is wrapped up so you don't have to feel the pain.

In theory, if you write all code exculsively in "managed" mode, which is default, it will run on any implementation of the CLI that has the libraries you've used. The is identical to the 100% pure Java program, for exactly the same reasons.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1