Posted on April 15, 2009 by redditech
This tip on using the double-quotation marks in C# helped me a bit today when it came to integrating new code for an ASP.Net web application with legacy data access code that I was unsure about the quality of. The data access code that I was referencing may or may not have null value checking, and there was no time because of an impending deadline to do code-review or quality control revision on it, but by using the ‘??’ check on values returned by it and some constant parameter values hydrated by web.config appSetting values II was able to implement default behaviour in my code for objects which did not get what was expected from the data access layer.
Of course this is just a band aid. The solution really lies in cleaning up that misbehaving code and defining standard contracts for behaviour between tiers that all the software team agrees to and which consistent code reviewing will reveal deviations from at earlier stages before integration, and perhaps the whole team becomes better developers because of it since we’re discipling ourselves on good practices for writing quality code.
Filed under: Tech Blurb | Tagged: ASP.Net, C# | Leave a comment »
Posted on February 27, 2009 by redditech
Thinking in terms of Delegates was always a bit of a challenge to me. So when I hit the Predicate parameter when trying to using a List<X>.FindAll(XType y).
The example given in discussion on this article went a long way to clearing this up. If I get more answers like this from Bytes I might start using this as my secondary source of programming answers after StackOverflow.
Filed under: Tech Blurb | Tagged: C# | Leave a comment »
Posted on January 29, 2009 by redditech
It’s always good to remember what a useful override of the ToString() method on any object can do. Perfect example is C# DateTime whose ToString() method can take parameters that determine the formatting of the returned value.
Examples for DateTime’s .ToString(“format“) method include the following (where format is replaced by the coding value assigned):
D :Thursday, August 17, 2000
f :Thursday, August 17, 2000 16:32
F :Thursday, August 17, 2000 16:32:32
g :08/17/2000 16:32
G :08/17/2000 16:32:32
m :August 17
r :Thu, 17 Aug 2000 23:32:32 GMT
u :2000-08-17 23:32:32Z
U :Thursday, August 17, 2000 23:32:32
y :August, 2000
dddd, MMMM dd yyyy :Thursday, August 17 2000
ddd, MMM d "'"yy :Thu, Aug 17 '00
dddd, MMMM dd :Thursday, August 17
Filed under: Tech Blurb | Tagged: ASP.Net, C#, DateTime | Leave a comment »