What are the most common or vicious mistakes when experienced C++ programmers develop in C#?
相关问题
- Sorting 3 numbers without branching [closed]
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- How to compile C++ code in GDB?
Attempting to implement
const
correctness onstring
s.One that got me, and I believe a lot of non C++ people too, was leaking memory due to registered events keeping an object alive.
IDisposable grated to begin with (and still does if I'm honest) but was pretty obviously going to be a difference when going from native to managed code so it is not something I'd expect C++ developers to actually fall foul of, they just won't like it.
struct
andclass
in the twousing
alias and atypedef
int
? (it is actually defined in C#)I've seen many C++ coders code in a COM style in C#, trying to deal with the inadequacies of the language. C# provides lots of a type safe support for your enums and there are usually nicer APIs then P/Invoking back down to C++.
The other thing I've seen catch most people out is that C# generics are not templates.
Calling
GC.Collect
.