I'm trying to use VS more efficiently, and I was looking for a way to generate a method automatically. For example, I know if you type foreach
then press TAB
twice it generates the skeleton code, so if I had a method like this:
[HttpPost]
public ActionResult CloseTicket()
{
//do stuff
}
Is there a way of generating the 'skeleton code' so I don't have to manually type it out. I looked into method stubs but they don't seem to apply to this.
There are built-in snippets in Visual Studio to help with this:
mvcaction4
inserts:
public ActionResult Action()
{
return View();
}
And
mvcpostaction4
Inserts
[HttpPost]
public ActionResult Action()
{
return View();
}
If it is not there you can create a code snippet. Just put in in the right folder and VS will use it.
For VS2013 put it in folder:
\\Documents\\Visual Studio 2013\\Code Snippets\\Visual C#\\My Code Snippets
See here how to create a code snippet https://msdn.microsoft.com/en-us/library/ms165394.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.