Click here to Skip to main content
15,922,533 members
Home / Discussions / C#
   

C#

 
AnswerRe: Complex Regular Expression Pin
MidwestLimey5-Oct-07 5:18
professionalMidwestLimey5-Oct-07 5:18 
GeneralRe: Complex Regular Expression Pin
Skippums5-Oct-07 5:36
Skippums5-Oct-07 5:36 
GeneralRe: Complex Regular Expression Pin
MidwestLimey5-Oct-07 6:08
professionalMidwestLimey5-Oct-07 6:08 
QuestionDownload File From Website With Login Pin
redfish344-Oct-07 11:39
redfish344-Oct-07 11:39 
AnswerRe: Download File From Website With Login Pin
Scott Dorman4-Oct-07 11:54
professionalScott Dorman4-Oct-07 11:54 
GeneralRe: Download File From Website With Login Pin
redfish344-Oct-07 12:24
redfish344-Oct-07 12:24 
GeneralRe: Download File From Website With Login Pin
Meysam Mahfouzi21-Sep-08 20:21
Meysam Mahfouzi21-Sep-08 20:21 
Questionparsing a string with DateTime.ParseExact Pin
dfn4-Oct-07 11:11
dfn4-Oct-07 11:11 
Hi.
I am having trouble parsing a string into the format I want.
Basically, I want the string to end up being "MMdd" where MM is the month (with a leading zero if necessary) and dd is the day (with a leading zero if necessary).

This is what I have tried:

String today = DateTime.Today.Date.ToShortDateString();
String pattern = "MMdd";
DateTime dt_today = DateTime.ParseExact(today, pattern, null); // line 3

today = dt_today.ToString();

Console.WriteLine("today's date is: " + today);


The problem is that my program crashes once run. If you look at the third line, in place of null, I have tried sending: System.Globalization.CultureInfo.InvariantCulture, System.Globalization.CultureInfo.CurrentCulture
Both yielded the same result. I have also tried using "Now" instead of "Today" in the first line.

What am I doing wrong?
I'd appreciate any help.
AnswerRe: parsing a string with DateTime.ParseExact Pin
Christian Graus4-Oct-07 11:34
protectorChristian Graus4-Oct-07 11:34 
AnswerRe: parsing a string with DateTime.ParseExact Pin
Luc Pattyn4-Oct-07 11:44
sitebuilderLuc Pattyn4-Oct-07 11:44 
AnswerRe: parsing a string with DateTime.ParseExact Pin
Scott Dorman4-Oct-07 11:51
professionalScott Dorman4-Oct-07 11:51 
AnswerRe: parsing a string with DateTime.ParseExact Pin
dfn4-Oct-07 11:59
dfn4-Oct-07 11:59 
JokeRe: parsing a string with DateTime.ParseExact Pin
Anthony Mushrow4-Oct-07 12:30
professionalAnthony Mushrow4-Oct-07 12:30 
QuestionHow to create Expander in WinForm? Pin
tantja4-Oct-07 11:04
tantja4-Oct-07 11:04 
AnswerRe: How to create Expander in WinForm? Pin
Christian Graus4-Oct-07 11:35
protectorChristian Graus4-Oct-07 11:35 
GeneralRe: How to create Expander in WinForm? Pin
tantja4-Oct-07 11:47
tantja4-Oct-07 11:47 
QuestionRe: How to create Expander in WinForm? Pin
TJoe4-Oct-07 12:14
TJoe4-Oct-07 12:14 
AnswerRe: How to create Expander in WinForm? Pin
tantja4-Oct-07 12:16
tantja4-Oct-07 12:16 
QuestionActivation or License Pin
andyr20054-Oct-07 10:25
andyr20054-Oct-07 10:25 
AnswerRe: Activation or License Pin
Ilya Verbitskiy4-Oct-07 10:48
Ilya Verbitskiy4-Oct-07 10:48 
AnswerRe: Activation or License Pin
TJoe4-Oct-07 12:11
TJoe4-Oct-07 12:11 
QuestionDataGridView button problem Pin
udikantz4-Oct-07 9:20
udikantz4-Oct-07 9:20 
QuestionIssues with Mutlithreading and STA [modified] Pin
Aaron VanWieren4-Oct-07 8:53
Aaron VanWieren4-Oct-07 8:53 
AnswerRe: Issues with Mutlithreading and STA Pin
led mike4-Oct-07 9:52
led mike4-Oct-07 9:52 
GeneralRe: Issues with Mutlithreading and STA Pin
Aaron VanWieren4-Oct-07 10:34
Aaron VanWieren4-Oct-07 10:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.