c# - Debug.WriteLine(string, params object[]) is a method but is used like a type -


i'm working on to-do list project , @ ending stages of development, syntax outputting debug seems incorrect, i'm not sure error , appreciated.

as shown above, error cs0118:

'system.diagnostics.debug.writeline(string, params object[]) method used type'

#define testing using system; using system.collections.generic; using system.diagnostics;  #if(testing)     public static string[] tempstringarr = new string[5]          { "hey", "greetings", "hello", "hi", "example" };     public static string tempkey = "hello";      public static int linearsearchtitletest(string titlekey, string[] titlearr)     {          (int = 0; < titlearr.length - 1; i++)         {             if (titlekey == titlearr[i])             {                 return i;             }         }         return -1;     }      int testresult = linearsearchtitletest(tempkey, tempstringarr);     debug.writeline(convert.tostring(testresult)); #endif 

your debug.writeline call not in scope of function. try put code in function, maybe in main() testing purpose?

int testresult = linearsearchtitletest(tempkey, tempstringarr); debug.writeline(convert.tostring(testresult)); 

for example :

class program {     public static string[] tempstringarr = new string[5] { "hey", "greetings", "hello", "hi", "example" };     public static string tempkey = "hello";      static void main(string[] args)     {         int testresult = linearsearchtitletest(tempkey, tempstringarr);         debug.writeline(convert.tostring(testresult));     }      public static int linearsearchtitletest(string titlekey, string[] titlearr)     {         (int = 0; < titlearr.length - 1; i++)         {             if (titlekey == titlearr[i])             {                 return i;             }         }         return -1;     } } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -