-
-
I always create property assessors for objects. But why? Maybe just in case I need them later.
Now, with VS 2008 there is a new feature, automatic properties.
Check them out, it will save you time.
-f.
ref: http://weblogs.asp.net/scottgu/archive/2007/03/08/new-c-orcas-language-features-automatic-properties-object-initializers-and-collection-initializers.aspx
-
-
After writing the same code over and over, I looked around to see I there was some libraries.
Wikipedia (as usual) as a pretty complete list. And I found that Dojo was one of the most complete.
-f.
ref:
http://dojotoolkit.org/
http://en.wikipedia.org/wiki/Dojo_Toolkit
-
-
hum... no, it’s not possible, but there is another way to do it.
Random r = new Random(Convert.ToInt32(DateTime.Now.Ticks-DateTime.Now.Ticks));
Catch it? Yes it will fail only if your computer is too slow to have more than an int32 of tick between two operation. (2,147,483,647 for an int32 /10000 ticks in a milliseconds, so it will fail if the time between a substraction is 214 seconds)
-f.
-
-
CSS is a good way to handle style and positioning of a webpage. Do you know that you can repeat the style ids and split the styling (like, colors) and the positioning (like left and top)?
The best way that I've found, two CSS, one with the positioning, and another with the styles, so if you want to dynamically change the color, you only have to change a CSS file.
-f.
-
-
When creating a ASP.Net web application, a code-behind page with the same name as the asp.net page is created, but you can avoid it.
The only directive required to be recognized as a ASP.NET page, is <%@ Page %>
-f.
-
-
If a dispose method exist, it is a good practice to call it when the immediate performance is not an issue, and when you want to optimize long term performance.
The call of the dispose method will be done by the Garbage Collector even if you are not calling it, but the resources will only be this disposed at this time.
-f.
-
-
Using the parse method of an object is always better than using a direct cast, when you do not know what is the type of the given object... and take a look at the “as” keyword, it can be helpful too.
-f.
-
-
When designing ASP.Net webpage, all protectected properties can be accessed with <%=propertyname%>
So, you can split UI from Business logic by wrapping code inside them.
-f.
-
-
Do you really know?
It is a MulticastDelegate that only allow to add and remove handlers, so, it’s like calling many methods, at one time...
-f.
ref:
http://blogs.msdn.com/ddietric/archive/2007/10/01/fun-with-events-and-delegates.aspx
http://www.codeproject.com/KB/cs/howeventswork.aspx
-
-
Comparing to way of locking.. lock(object){ } and Monitor.Enter() and Monitor.Exit().
It is the same! But the better way to do it, is to use the lock statement, because you can always forget to Monitor.Exit() or an error can throw an exception before it is called.
-f.
ref:
The lock keyword calls Enter(Object) at the start of the block and Exit(Object) at the end of the block.
http://msdn.microsoft.com/en-us/library/c5kehkcz.aspx
-
-
(Almost) everybody knows that typing /// in front of a method generates XML comments. But it does not apply only to method, but to classes, namespaces, and property accessors.
... and there are 11 more tags! <c>, <code>, <list>, <listheader>, <item>, <term>, <description>, <para>, <paramref>, <see>, and <value>
-f.
ref:
http://msdn.microsoft.com/en-us/magazine/cc302121.aspx
-
-
When it’s time to isolate code into component, a good way to do it easily is to remove namespaces from classes and references from assembly…
Removing Windows.Form remove the entire Windows Form layer from the class, and separate the component. Removing the System.Web assemblies split your presentation layer from the Application Layer...
-f.
-
-
There a lot to URIParser than the HTTP and File scheme, LDAP, TCP, Gopher and many other, check them out
-f.
ref.:
http://msdn.microsoft.com/en-us/library/system.uriparser.aspx
-
-
Get the system up by getting the System.Environment.TickCount .
-f.