.net - C# Beginner problems -


i have "debug" class, prints information console etc. rest of code want able call methods within it, far it's partly working.

calling dc.print() works fine, call dc.print(dc.geteventslogged()) red line message

"the best overloaded method match has invalid arguments" argument 1: cannot convert 'int' 'string'.

basically: why arguments dc.print wrong? also, can "cannot convert int string? tried .tostring didn't work either.

this "debug.cs" class:

using system; using system.collections.generic; using system.linq; using system.text;   namespace test {     public class debug     {         private int events_logged;          public debug()         {             events_logged = 0;         }          public void print(string message)         {             console.writeline("[" + datetime.utcnow + "] " + message);             events_logged++;         }           public int geteventslogged()         {         return events_logged;         }     } } 

and in "program.cs" class have:

using system; using system.collections.generic; using system.linq; using system.text;  namespace test {     class program     {         static void main(string[] args)         {             debug dc = new debug();             dc.print("test");         }     } } 

the reason seeing error because geteventslogged() returns int whereas print() expects pass in string. therefore need return int string , on right track tostring(). want achieve:

dc.print(dc.geteventslogged().tostring()); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -