The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer.
 Thursday, June 12, 2003
Getting the Line Number and File Name from C#

Someone wanted to know what the equivalent "preprocessor macros" in C# are for __FILE__ and __LINE__.  They watned to log the current file name and line number.  Note that the "1" as the first parameter to the StackFrame constructor tells it to skip ONE frame up the stack, while the true tells it to capture the file and line info.

[STAThread]
static void Main(string[] args)
{
     ReportError("Yay!");
}

static private void ReportError(string Message)
{
     StackFrame CallStack =
new StackFrame(1, true);
     Console.Write("Error: " + Message + ", File: " + CallStack.GetFileName() + ", Line: " + CallStack.GetFileLineNumber());
}


Updated Link to this post 1:23:21 PM  #    comment []  trackback []
A Test of Google and Blogs: Selling my wife's car

This is not really technical or .NET related, but hey.  The signal-to-noise ratio is still high around here, eh? :)

So, my wife bought herself a Honda Civic Hybrid, as previously posted, and we need to sell her '97 Mitsubishi Mirage DE Coupe.  I suppose I could post adds on Vehix.com and http://www.oregonlive.com or <gasp> the newspaper.   But, I could also (possibly) take advantage of the power of Google, Weblogging and Keven Bacon and post the link here: http://www.computerzen.com/carforsale

Then, I sit back and hope that this thrilling blog post is linked to furiously, driving my site up the Google Page Ranks system to the point where ANYONE in Oregon who even THINKS, "Used Cars Oregon," "Good Used Car Oregon" or "Mitsubishi Oregon" will be magnetically sucked into my world and compelled to purchase.

Updates on this crucial experiment as the queries pour in.

Or, could I just use the Nickel Ads...


Updated Link to this post 9:49:44 AM  #    comment []  trackback []