public static string TrimToNull(this string str) { if (str == null || str.Length == 0) return null; else { str = str.Trim(); if (str.Length == 0) return null; else return str; } }