I get the CA2202 warning on the following piece of code
using (MemoryStream msDecrypt = new MemoryStream(encrypted))
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
return srDecrypt.ReadToEnd();
This code is triggering on both msDecrypt and csDecrypt having their own using statements. Is there a preferred object to dispose of? The outer (msDecrypt) or the inner (csDecrypt)- and if so why?
This question is not a duplicate of this thread because I want to know generally speaking - which is better to dispose of - the inner/later object or the outer/earlier object and why?