Okay, this is going to be a very embarrassing question for me, but I nonetheless need to adopt the best practices for writing code.

I need to know what is the best way of keeping my code from breaking. I understand that I should probably write methods that are of themselves fail-safe. I should probably validate all the arguments passed to a method and throw an exception when an argument is invalid or will cause the code to break. I should also probably validate conditions after the meat of the method has done its job, and throw an exception if that isn't right. (Although I would like some explanations about this to solidify the concept.)

I have several situations that I can think of where I can keep my code from breaking, but it requires that I employ exception handling strategies that I am not intimate with. Something very simple like refusing to accept a property value which is an array if it contains a null reference I would have a little trouble with, simply because I do not know what the is the right exception to throw in that situation. Some exceptions I know what to do with are, ArgumentNullException, ArgumentException, and quite a number of others that are more specific to .NET APIs. But I do not know the proper exception to throw when the argument is a collection that has an invalid value, or when it is not an argument, but a property value, whether it is being set a the time or being used for some purpose.

I need to know these very fundamental things. I am already familiar with many other things that are far more advanced, but playing around in my personal time I have not made my code solid. It is, however, required of me to implement fail-safe code. (Please don't comment on this matter.) So, I would like some information on how to best go about this, because I no longer wish to go by sloppy coding practices.

Thanks in advance for the help.