[SOLVED] How can I create new c# scripts in the editor via code?

Let’s say when the user pushes a button, I want it to create a new c# script, and also dynamically edit code from a c# script by just clicking some buttons in the inspector. How can this be achieved?

System.IO.File.WriteAllText(path, string) to write script into a file, now all you need is to assemble the string from your desired script