Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


c++, c# and pointers

This topic is 5650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello to everybody it seems that c# is slight slower than c++ but much easier to use. If so ,I switch to c# immediatly. Being an amateur I do not care about performance. However I understood that c# does not use pointers or , better said, it does not encourage the use of pointers ( unsafe coding or something like that )while all the game programming books I own ,make an extensive use of pointers. It is well known that very often programmers abuse of pointers. in other words they use them even when they are not strictly necessary. On the other hand in some other case pointers are a must, unless of course you are willing to accept serious costraints. In conlusion what about c++, c# and pointers ? thanks in advance

Share this post

Link to post
Share on other sites
C++ uses pointers mostly because that was the only way in C to get reference semantics. In C#, almost everything is accessed through references, so it has little need for pointers in most scenarios.
In the niche scenarios where you do need pointers, you can have them in special sections of code marked as unsafe.

"I know very well who Satan is: He is freedom. He is the uncontrolled, the incalculable, the antithesis of order and discipline, the antithesis of the legalism of outer space.... We know where a planet will be in twelve years, four months and nine days. But we don''t know where a butterfly will have flown one minute hence. Therefore the butterfly is of Satan."
-- Jens Bjørneboe

Share this post

Link to post
Share on other sites
Well, actually references ARE pointers :-)

What C# does not support is pointer arithmetics - this pointer++ stuff etc. A reference is a pointer - you can assign it (validly), and it can be invalid (null). But with missing pointer arithmetics, you can never make a valid pointer point to invalid space (thanks to the GC, too).


Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!