Sorry about the rather cryptic headline - guess I find it difficult to describe the problem (guess too that that is the reason for me not being able to google me to an answer).
Anyway here we go:
I have created a class file (LogWriter.cs) which simply writes something to a database depeding on calling inputs:
public class LogWriter
{
public LogWriter(string myValue)
{
//WRITE TO DB....
Now I want to be able to call this from my other cs-files. F.ex. from LogIn.cs
How do I do that - I keep getting "Project1.LogWriter' denotes a 'class' which is not valid in the given context" - that is when I just directly call it like this:
LogWriter("test");Just create an instance of that class within all of the classes you need to use it.
Example:
LogWriter LW = new LogWriter();
LW.Write("test");Another option is to change the class to a public module. Then you could directly call the method without first instantiating an instance of the class.
Anyway here we go:
I have created a class file (LogWriter.cs) which simply writes something to a database depeding on calling inputs:
public class LogWriter
{
public LogWriter(string myValue)
{
//WRITE TO DB....
Now I want to be able to call this from my other cs-files. F.ex. from LogIn.cs
How do I do that - I keep getting "Project1.LogWriter' denotes a 'class' which is not valid in the given context" - that is when I just directly call it like this:
LogWriter("test");Just create an instance of that class within all of the classes you need to use it.
Example:
LogWriter LW = new LogWriter();
LW.Write("test");Another option is to change the class to a public module. Then you could directly call the method without first instantiating an instance of the class.