Jelle Druyts .NET Consultant
Just another ignorant weirdo from Antwerp, Belgium trying to make sense out of it all
Although .NET is mainly targeted at Windows right now, it's obvious from the Mono Project (now in beta 2 phase!) and other initiatives like the SSCLI that running .NET code on other platforms is either already possible, or within reasonable reach. So how do you take that into account when developing in .NET?
Personally, I knew I was doing the "right thing" all along because it just felt right, but it's nice to see that reflected by 'trusted sources' once in a while: Scott Hanselman takes some gems away from nGallery's Mono compliance and sprinkles them with a little of his own fairy dust. Also, Clemens Vasters just noticed that there's a dasBlog port on mono. These accomplishments are both pretty impressive.
So here's the aggregated wisdom, with a personal topping to cover it up:
System.Environment.NewLine
System.IO.Path.DirectorySeparatorChar
string fullPath = directoryName + @"\" + fileName;
directoryName
string fullPath = System.IO.Path.Combine( directoryName, fileName );
I'd like to see that first point supported in the framework just a little better though, since not using Environment.NewLine is just that tiny bit easier. Compare
Environment.NewLine
Console.WriteLine( "Exception details:\r\nMessage: {0}\r\nStack Trace:\r\n{1}", e.Message, e.StackTrace );
to
Console.WriteLine( "Exception details:{0}Message: {1}{0}Stack Trace:{0}{2}", Environment.NewLine, e.Message, e.StackTrace );
Arguably, the second one does look a bit cleaner, but it's still more cumbersome with the extra parameter. So, an extra escape character indicating a new line (regardless of the platform) would be nice. Who cares about those 'return' and 'newline' codes anyway these days.
Other than that: stick to the rules and on one beautiful day, you just might find yourself running on Linux. And why not, why not indeed.