In the case of the method you show, in order to call it you need an instance of the containing class: an example of the class that the method is part of, created at some point with the
new
keyword:
MyClass mc = new MyClass();
...
mc.dbConnection();
If you change it to a
static
method:
public static void dbConnection(string ProjectName112)
{
string strProject = ProjectName112;
}
Then you don;t need the instance, you can just use the class name:
MyClass.dbConnection();
But then the method can't access any non-static field, properties or methods of the MyClass class.
But...the example you show does nothing useful: it returns no value, and the string variable
strProject
is destroyed when the method exits, so nothign will influence the outside world.
I think you need to think a bit about exactly what you are trying to achieve here: this probably isn't going to work...