tonelm54
asked on
constructor not working
Im quite new to c# and working on my first project.
What Im trying to do is create a mass of objects in my case a load of directories, eventually I want to process the files in the directory, but at the moment concentrating on getting the framework working.
So what I have so far is:-
So to call this in my main program, I want to be able to run something like:-
However I keep getting advised that my constructor doesnt accept my parameters.
What am I doing wrong????
What Im trying to do is create a mass of objects in my case a load of directories, eventually I want to process the files in the directory, but at the moment concentrating on getting the framework working.
So what I have so far is:-
class directory
{
public directory(String directory, ref worker worker)
{
if (worker.canIrun())
{
worker.runNew("x:\newDirectory");
}
}
}
class worker
{
public worker(String directory)
{
this.runNew(directory);
}
public void runNew(String directory)
{
directory newDirectory = new directory(directory, this);
}
public Boolean canIrun()
{
return true;
}
}
So to call this in my main program, I want to be able to run something like:-
worker newWorker = new worker("c:\\firstDirectory\\);
However I keep getting advised that my constructor doesnt accept my parameters.
What am I doing wrong????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just to add about coding standards. In a team it's very important. Please see MS notes:
http://msdn.microsoft.com/en-us/library/vstudio/ms229043(v=vs.100).aspx
http://msdn.microsoft.com/en-us/library/vstudio/ms229043(v=vs.100).aspx
directory newDirectory = new directory(directory, this);
You have a parameter called directory, a variable type called directory and a method called directory. A bit of a mess really.
Try changing the names.