Yes, but they are much harder to produce. You can only get buffer overflows if you use certain unsafe constructs, not with “normal” C# code. Memory corrupting code shouldn’t be possible at all, when your code is running with lowered trust.
A few possibilities for buffer overflows:
- Using the
unsafekeyword, which allows pointers. Unsafe code is just as easy to get wrong, as pointer based code in C or C++. - Using unsafe APIs, such as the methods from the
Marshalclass - (Mono only) You can disable array range checking (safety vs. performance trade-off)
There are also a few other ways to corrupt memory apart from buffer overflows.
StructLayoutKind.Explicit- Wrong native interop signatures
(The runtime itself is written in C++, so a bug in the runtime can also corrupt memory or overflow a buffer, but I consider that out of scope for this question)