Tuesday, December 23, 2008

Compare mobile phone Cap Plans

found this tool very useful
http://www.mobchoice.com.au/compare-cap-plans-spreadsheet

Wednesday, December 10, 2008

string.format new line partially works (C#, ASP.NET)

see below my code. every "\n" works fine except the ones after "Event: {0}" and "Start Date: {1:D}", basically the Event, Start Date and End Date are printed on same line. can anyone help please? thanks in advance.

string.Format(



"Schedule Details: \n" +

"Event: {0}\n"+


"Start Date: {1:D} \n" +

"End Date: {2:D} \n" +

"Location: {3} \n"


,schedule.event,
schedule.startDate,
schedule.endDate,
schedule.location);

I tried ""Event: {0}"+ Environment.NewLine" and "Event: {0}\r" and "Event: {0}/r/n" got the same result
==============

Schedule Details:

Event: Basketball Match Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009

Location: Como
================

Then I tried "Event: {0}\n"+ Environment.NewLine" and "Event: {0}\r"+ Environment.NewLine" and "Event: {0}/n/r" got this result (an additional line)
==============


Schedule Details:

Event: Basketball Match

Start Date: Friday, 1 May 2009 End Date: Tuesday, 30 June 2009

Location: Como
================

It seems that it works either for no newline or 2 new lines, but not for 1 newline. I tried to take out "Event" everything else worked just fine, so the problem must be with "Event"?

The Event has datatype of "string", startDate and endDate are datetime, location is string. A sample of Event value is "Attend Class Certificate III in Basketball".

Eventually the problem is solved, not sure why though.....:

I put single quotes around the Event value, not sure how exactly but it worked.
"Event: '{0}'\n"+