I am creating my first site in C #.
I noticed that I am getting some duplication of extension methods in intellisense. Further research was as follows:
public static void ThrowNullOrEmpty<T>(this IEnumerable<T> obj, string param) { } public static void ThrowNullOrEmpty(this string obj, string param) { }
It seems the string could also be an IEnumerable<char> .
From the compilation base I can remove the line option, but are there any performance issues or anything else I should know about?
UPDATE
Just tested over 1 m iterations.
public bool IsNullOrEmpty1(string @this) { return String.IsNullOrEmpty(@this); }
vs
public bool IsNullOrEmpty2<T>(IEnumerable<T> @this) { return @this == null || !@this.Any (); }
IsNullOrEmpty1 synchronized 12 ms on my IsNullOrEmpty2 development machine (125 - 250 ms), so itβs 10-20 times slower.
In the real world, I took an extremely high figure of 30 m iterations per month, which corresponds to 1388 per minute (12-hour work day). The result was less than 1 ms for both.
So, removing IsNullOrEmpty1 is not the best approach, but it is not a site killer.
source share