using System.Text.RegularExpressions;
using System.Collections.Generic;
public static void Main()
var tc = new TestClass();
tc.IdentifyNullParameters();
catch (AggregateException ae)
Console.WriteLine(ae.InnerException.Message);
if (string.IsNullOrWhiteSpace(value))
throw new Exception("Organization name cannot be null, empty, or whitespaces.");
public SomeOtherClass SomeOtherClass { get; set; }
public void IdentifyNullParameters()
var exceptionList = new List<Exception>();
this.GetType().GetProperties().ToList().ForEach(x =>
if ((x.GetValue(this, null) == null)
|| string.IsNullOrWhiteSpace(x.GetValue(this, null).ToString()))
exceptionList.Add(new Exception(x.Name));
if (exceptionList.Count > 0)
throw new AggregateException(exceptionList);
public class SomeOtherClass
public int SomeOtherProperty { get; set; }