I am trying to have a datastructure of an abstract class so I can access a method of different objects implementing that abstract class. This is my code:
using Subsync.App;
List<App> installed_apps = new List<object>();
public Views (string[] args)
{
//INSTALL APPS HERE.
installed_apps.Add (new HelloWorld.HelloWorld ());
//INSTALL END
foreach (App app in installed_apps) {
foreach (KeyValuePair<string, List<object>> match in app.getTokens ()) {
tokens.Add (match.Key, match.Value);
}
}
//begin dispatch
Dictionary<string,List<object>> tokenized = Tokenize(args);
Dispatch(tokenized);
}
In namespace Subsync:
public abstract class App
{
public abstract Dictionary<string, List<object>> getTokens ();
}
In namespace HelloWorld:
public class HelloWorld : App
{
public HelloWorld ()
{
}
public override Dictionary<string, List<object>> getTokens ()
{
Dictionary<string, List<object>> ret = new Dictionary<string, List<object>> ();
ret.Add("helloworld",new List<object>() {"0","-hw","-helloworld"});
return ret;
}
}
Compiling gives me the error
Error CS0246: The type or namespace
name `App’ could not be found. Are you
missing a using directive or an
assembly reference? (CS0246) (App)
All the code files are in the same project folder. What am I doing wrong? Thanks!
place abstract as the first class modifier, rather than public.