c# - Can I Make Extension Methods For System.IO.Path Class? -


this question has answer here:

how can make extension method system.io.path class mean need below:

path.getextension(sfilepath)  

i want make method:

path.getmimetype(sfilepath) 

extension method:

public static string getmimetype(this path spath,string sfilepath) {         string sextension = path.getextension(sfilepath).tolowerinvariant();          if (sextension.length > 0 && dicmimetypes.containskey(sextension.remove(0, 1)))         {             return dicmimetypes[sextension.remove(0, 1)];         }         return "unknown/unknown"; } 

but when compile above code method error ('system.io.path': static types cannot used parameters).

thanks all,

path static, , therefore cannot create extension method it. extension methods require instance of object.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -