They’re identical.
UTF8Encoding
inherits Encoding
.
Therefore, you can access all of the static members declared by Encoding
through the UTF8Encoding
qualifier.
In fact, you can even write ASCIIEncoding.UTF8
, and it will still work.
It will compile to identical IL, even in debug mode.
I would recommend using Encoding.UTF8
, as it shows what’s going on more clearly.