error: list<> does not contain a definition for ' '
Hi all,
I'm getting this error for my following program, can anyone explain the below error and how can i solve it?
thanks in advance.
error CS1061: 'System.Collections.Generic.List<AbstractSyntax.Declaration>' does not contain a definition for 'toStringIndented' and no extension method 'toStringIndented' accepting a first argument of type 'System.Collections.Generic.List<AbstractSyntax.Declaration>' could be found (are you missing a using directive or an assembly reference?)
in my abstractsyntax.cs:
public class CProgram { List<Declaration> decpart = new List<Declaration>(); List<Statement> body = new List<Statement>(); public CProgram(List<Declaration> d, List<Statement> b) { decpart = d; body = b; } public String toString() { return toStringIndented(""); } public String toStringIndented(String indent) { return indent + "Program(\n" + decpart.toStringIndented(indent + " ") + ",\n" <-- error + body.toStringIndented(indent + " ") + "\n" <-- error + indent + ")"; } }public class Declaration { public List<Declaration> decl = null; public Declaration() { } public Declaration(List<Declaration> Declarations) { this.decl = Declarations; } public String toString() { return toStringIndented(""); } public String toStringIndented(String indent) { StringBuilder sb = new StringBuilder(); sb.Append(indent); sb.Append("Declarations(\n"); int i = 0; foreach (Declaration s in decl) { sb.Append(this.toStringIndented(indent + " ")); i++; if (i == decl.Count) sb.Append("\n"); else sb.Append(",\n"); } sb.Append(indent); sb.Append(")"); return sb.ToString(); } }