Thursday, May 14, 2020

Handy way to skeleton code a needed function in C#, so you can build without errors.

So I developed this technique years ago whilst Java was my primary coding language.  It's a great way to put a place holder method in while you're still writing code in another class or method.  I'm going to use C# today as that is primarily what I am coding with these days, and when I start talking about Asp .Net Core development that will be the language we will be using.

So if I need to place a call to a method that I haven't written yet, what I will do is quickly code a skeleton first like this.

public int myMethod()
{
    int returnValue = 0;



    return returnValue;
}

This way I can keep coding my main section as I want without Visual Studio, or Visual Studio Code complaining about a non-existent method call. Also, it will enable any test builds. This is especially useful for Asp .Net Core projects that involve Entity Framework as you need to be able to build to perform migrations or database updates.


Take care, my nerds!!!

No comments: