Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug.WriteLine overloads seem to conflict

In C#.Net, System.Diagnostics.Debug.WriteLine has several overloads, including these two:

//http://msdn.microsoft.com/en-us/library/cc190153.aspx
public static void WriteLine(string format, params Object[] args);

//http://msdn.microsoft.com/en-us/library/1w33ay0x.aspx
public static void WriteLine(string message, string category);

My intention is to call the first one with:

Debug.WriteLine("The path is {0}", myObj.myPath);

But it appears that I'm actually calling the second overload, because it is a more exact match.

Is there a simple way to indicate that I want the first one?

My best attempts so far are:

Debug.WriteLine("The path is {0}", new object[]{myObj.myPath});
Debug.WriteLine("The path is {0}", myObj.myPath, "");

But neither of these looks very elegant.

like image 870
abelenky Avatar asked Aug 12 '13 15:08

abelenky


1 Answers

Try this:

Debug.WriteLine("The path is {0}", (object)myObj.myPath);
like image 118
Daniel Hilgarth Avatar answered Sep 21 '22 09:09

Daniel Hilgarth