public static DateTime ToDateTime(this string date)
{
DateTime date1 = DateTime.MinValue;
string[] dateArr = null;
try
{
dateArr = date.Split(’.');
if (dateArr.Length >= 3)
[...]
public static DateTime ToDateTime(this string date)
{
DateTime date1 = DateTime.MinValue;
string[] dateArr = null;
try
{
dateArr = date.Split(’.');
if (dateArr.Length >= 3)
[...]
string strDay = date.Day.ToString();
string strMonth = date.Month.ToString();
string strYear = date.Year.ToString();
outDate = string.Concat(strDay, ".", strMonth, ".", strYear);
Find the error:
XmlDocument doc = new XmlDocument();
doc.LoadXml(xml);
XmlElement root = doc.DocumentElement;
if ( doc == null )
{
throw new InvalidDataException("No valid xml");
}
………….
private string twoDigits(int s)
{
if (s < 10)
return "0" + s.ToString();
else
return s.ToString();
}
Clever people would use:
return s.ToString("D2");
That`s it, I have had enough of awesome code snippets I keep finding in projects I work on. Some of the stuff I find is just too awesome to not be shared with the world. There for from today on I will post the gems I find in the new born category “Code Bash” [...]
You are currently browsing the archives for the Code Bash category.