views:

166

answers:

2

Hello,

First off, I know this may be a very stupid question, so don't shoot me for asking it.

I come from C++ background, and I love C++ to death, but now that I've been using C# for a while, I've grown to love C#. BUT, I miss the coding style of C++ and sometimes wish I could go back, but C# is just so time-saving now compared to C++ that I don't think I could go back.

My point is, is there a way to code in C# that would make me feel like I'm actually writing C++ code? I guess what I mean is, can I write unmanaged code in C# without breaking things?

+4  A: 

Maybe you would like C++/Cli instead of C#:

http://en.wikipedia.org/wiki/C%2B%2B/CLI

It is not good style to use unsafe (pointers etc.) code, if that is want you mean, in C# unless it is strictly necessary.

Unsafe code examples:

http://msdn.microsoft.com/en-us/library/aa288474(VS.71).aspx

As you can see, objects have to be fixed at a memory location when using pointers which can lead to bad performance for the GC.

lasseespeholt
Hmm, thanks; This looks very interesting :D (C++/Cli)
lucifer
+3  A: 

No, there is no way to make C# feel like C++. You will miss pointers and multiple inheritance. Get over it, chose the language that gets the job done.

Code Clown
There is pointers in C# (see unsafe code).
lasseespeholt
@lasseespeholt Yes, but unsafe code should be used as little as possible.
Petar Minchev
@Petar Agreed, see my answer.
lasseespeholt
Thanks Code Clown. I've always found C++ to get the job done for what I've had to do, and I don't want to be using unsafe code just for the sake of better coding style so...
lucifer