If you wrote a C# program and part of the code was written using the unsafe
key word, would that code still be considered "managed" code?
ie. would it be running under the CLR?
"Managed code" does not help you think about the unsafe
keyword correctly. The most fundamental aspect about managed code is that it is compatible with the garbage collector. It must be able to find object references back that are used by that code so it can properly determine whether the object is in use. That requires one very specific detail, at runtime the GC must be able to find a table back that describes where object references are stored. Local variables and method arguments are the tricky ones. That table is generated by the just-in-time compiler or by an ahead-of-time compiler like Ngen.exe or .NET Native.
C# always generates managed code, there is no option to generate methods that the GC cannot probe. Generating unmanaged code in a .NET assembly is possible, the C++/CLI compiler can do that. Implied is that C# code always requires the CLR, you don't have GC without it.
What is highly specific to unsafe
code is that it is not verifiable. It uses MSIL instructions that the just-in-time compiler cannot check to ensure that it won't corrupt memory. Pointers being the most obvious case, the jitter cannot know if a pointer dereference is safe, it doesn't know the pointer value yet.
The consequence of unverifiable code is that somebody can load your assembly in a sandbox and insist that all code must be verifiable. It won't work. And the ultimate consequence of course, you fumble the code and write to an arbitrary address in memory, producing a very difficult bug to diagnose. Losing a week of your life finding that bug is expected.