I'm new to C# and was practicing throwing Exceptions. Is it good practice to throw an exception from a helper method to shorten the amount of code needed? Like so:
public static void ThrowExcIfNull<T>(T[] array)
{
if (array == null) throw new ArgumentNullException("Array is null");
}
/// <summary>
/// Does Something
/// </summary>
/// <param name="x">The int array to be used</param>
/// <exception cref="ArgumentNullException">Thrown when the string is
/// null</exception> //Is this correct?
/// <returns>Some integer</returns>
public static int SomeMethod(this int[] x)
{
ThrowExcIfNull(x);
//Some code here
}
Also, would it be okay to write the documentation saying that "the exception is being thrown from someMethod"? Any information would help! Thanks