Best Practices for ArgumentException

Hello, I wish to enquiry what is the best practice to use ArgumentException. So far I got a dilemma. To use "return" or ArgumentException. For example we have the following 2 sample code. Which one should we use?

private void DeepCopy(object[] i_Lhs, object[] i_Rhs)
{
if(i_Lhs == null) throw new ArgumentNullException("Lhs cannot be null.");
if(i_Rhs == null) throw new ArgumentNullException("Rhs cannot be null.");
if(i_Lhs.Length != i_Rhs.Length) throw new ArgumentException("Lhs length must be the same as Rhs length.");

for(int i = 0; i < i_Rhs.Length; i++)
{
i_Lhs[i] = i_Rhs[i];
}
}

private void DeepCopy(object[] i_Lhs, object[] i_Rhs)
{
if(i_Lhs == null) return;
if(i_Rhs == null) return;
if(i_Lhs.Length != i_Rhs.Length) return;

for(int i = 0; i < i_Rhs.Length; i++)
{
i_Lhs[i] = i_Rhs[i];
}
}
[989 byte] By [yong2579] at [2007-11-19 23:18:23]
# 1 Re: Best Practices for ArgumentException
IMO if a function fails to perform its work due to some kind of exceptional condition - then you should throw an exception.

So, I would use the first one. In the last solution you would have no indication if something fails.

- petter
wildfrog at 2007-11-9 12:18:16 >