I am learning an extension method, a very handy feature that can save hours of coding, provides reuse. what I do now, days, every day I create 10 extension methods that are useful in a daily scenario. but I don’t get how to use these extension methods, every time we need to add a dll and reference it. or is there some smart way where we can use.
Let's pretend that
public static bool isValidMail(this string str) { Regex reg = new Regex(@"^[\w-\.] +@ ([\w-]+\.)+[\w-]{2,4}$"); return reg.IsMatch(str); }
if I created 100 extension methods like this, then for each project I will need to refer to this static class DLL. since I work with multiprocessor projects. Is there a way that we can put these extension methods in a centralized location or some kind of build cache where we can easily add a using statement and access all the static methods.
can we do this?
whenever we create a new project, VS automatically adds the extension methods that we created, so that in the evey project we can access it. instead of adding dll every time
I want to know how you do it. I hope no one votes, just curious how to implement extension methods
Ravi gadag
source share