String.Format - I'm sure there must be a worse way to do this.
-
var sbMonth = new StringBuilder();
try
{
int x = 1 / month.Length -1;
sbMonth = AppendMonth(sbMonth);
}
catch
{
sbMonth = AppendMonth(sbMonth, "0" + month);
}private StringBuilder AppendMonth(StringBuilder sb, string s)
{
string x = sb.Append(s).ToString();
StringBuilder y = new StringBuilder();
return y.Append(x);
}Giraffes are not real.
-
I'm a bit surprised there isn't an embedded String.Concatenate call in there as well.
DateTime dt = DateTime.Now;
// Get year, month, and day
string year = dt.Year.ToString();
string month = dt.Month.ToString();
string day = dt.Day.ToString();// Format month
if (month.Length == 1){ month = "0" + month; }// Format day
if (day.Length == 1){ day = "0" + day; }string DocumentName = string.Format("Application - [{0}] - " + year + month + day, this.Person.RegistrationNo.ToString());
I'm thinking that there is a ToString() call missing just before the final ; too. Oh - and this one too.
TRIMSDK.Location trimLocation = trimLocation = trimManager.FindLocationFromNickname(string.Format("{0}", this.Person.RegistrationNo.GetValueOrDefault(0).ToString()));
I think I need a Rum! :wtf:
You need to understand that a thing like this,
string DocumentName = string.Format("Application - [{0}] - {1:yyyyMMdd}", Person.RegistrationNo, DateTime.Now);
was not easy to understand and it could trick less experienced developers!!! Cheers!!!
-
You need to understand that a thing like this,
string DocumentName = string.Format("Application - [{0}] - {1:yyyyMMdd}", Person.RegistrationNo, DateTime.Now);
was not easy to understand and it could trick less experienced developers!!! Cheers!!!
-
Well it is flagged as a joke, also I hope my tone was sarcastic enough. Cheers
-
Well it is flagged as a joke, also I hope my tone was sarcastic enough. Cheers
-
ok, now where's my mind bleach?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
Thanks!
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
You're welcome!
I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. Stephen Hawking
-
I'm a bit surprised there isn't an embedded String.Concatenate call in there as well.
DateTime dt = DateTime.Now;
// Get year, month, and day
string year = dt.Year.ToString();
string month = dt.Month.ToString();
string day = dt.Day.ToString();// Format month
if (month.Length == 1){ month = "0" + month; }// Format day
if (day.Length == 1){ day = "0" + day; }string DocumentName = string.Format("Application - [{0}] - " + year + month + day, this.Person.RegistrationNo.ToString());
I'm thinking that there is a ToString() call missing just before the final ; too. Oh - and this one too.
TRIMSDK.Location trimLocation = trimLocation = trimManager.FindLocationFromNickname(string.Format("{0}", this.Person.RegistrationNo.GetValueOrDefault(0).ToString()));
I think I need a Rum! :wtf:
I would think this is how it's supposed to be done.
string Daternator()
{
DateTime dt = DateTime.Now;string result = ""; // Failure to use String.Empty - Check // Homemade string concat - Check for (int i = 0; i < 3; i++) { if (i == 0) result += dt.Year.ToString() + ", "; else if (i == 1) result += dt.Month.ToString() + ", "; else if (i == 2) result += dt.Day.ToString() + ", "; // Unnecessary code - Check } // More unnecessary code to fix previous unnecessary code - Check result = result.Remove(result.LastIndexOf(" "), 1); result = result.Remove(result.LastIndexOf(","), 1); // My lord, he wouldn't... Start: // And what's this? Regex? Fancy! MatchCollection mc = Regex.Matches(result, @"\\b(\\d)\\b"); // I like where this is headed... foreach (Match m in mc) { if (m.Success) { result = result.Insert(m.Index, "0"); goto Start; // Oh lord, he did, a goto loop - Check } } // Sweet sciency magic we have a result!! return string.Format("Application - \[{0}\] - " + result, this.Person.RegistrationNo.ToString());
}