Null out parameters in C#?

后端 未结 6 1132
深忆病人
深忆病人 2021-01-17 11:19

After reading on stackoverflow that in the case of checking the format of a DateTime you should use DateTime.TryParse. After trying some regex expressions they seem to get l

6条回答
  •  清酒与你
    2021-01-17 11:49

    TryParse is a better option. Its just a variable that is wasted. Other options include using the Convert.ToDateTime() within a try-catch block. But again that would not be efficient because try-catch blocks are meant to be heavy. The next option is regex. This is a better solution. I guess this gives you the result instantly than compared to the others.

    You can very well wrap the method like Kim Gräsman said...

提交回复
热议问题