Many thanks for reply, Sorry can you explain about "FirstOrDefault" , i got error monocecil does not contain a definition for "FirstOrDefault" , i use library from "http://anonsvn.mono- project.com/source/trunk/mcs/class/Mono.Cecil/" or is there any different build.
Thanks On Jun 18, 2:28 pm, Jb Evain <[email protected]> wrote: > Hey, > > On Fri, Jun 18, 2010 at 3:19 PM, david khan <[email protected]> wrote: > > TypeDefinition type = > > assembly.MainModule.Types["test.Form1"]; > > assembly.MainModule.Types.Remove(type); > > Please upgrade to Cecil 0.9.3. > > http://github.com/jbevain/cecil > > > So can anybody advice how to delete methods and is there simple way to > > delete like if i want to delete method "aa" of type "Form1" , just > > give url of assembly like that > > type.Methods.Remove("test.Form1.aa"); > > You can solve that very easily with an extension method: > > public static void RemoveMethod (this TypeDefinition self, string methodName) > { > var method = self.Methods.FirstOrDefault (m => m.Name == methodName); > if (method == null) > return; > > self.Methods.Remove (method); > > } > > Note that this will delete the first method with the specified name, > and it's common to find methods with the same names. > > -- > Jb Evain <[email protected]> -- -- mono-cecil
