Strings are immutable. In other words, a string can not be changed once assigned. When you append a string to an existing string, the .NET framework actually creates a new string containing the original string and the appended string. This is a resource-hungry and time-consuming process. The alternative to appending strings, is the StringBuilder class [...]
Continue reading about Improve String Management with StringBuilder
Assume we have a datarow field, name, which evaluates to null. What is the result of the following two cases? CASE A string name = Convert.ToString(dr["name"]); CASE B string name = dr["name"].ToString(); In the first case, Convert.ToString() will evaluate to null. In the second case, however, .ToString() will throw an exception. And it makes sense, [...]
Do you know how to short-circuit operators? In C#, And (&) and Or (|) operators evaluate both boolean expressions in the statement. However, the && operator only evaluates the first Boolean if false and the || operator only evaluates the first Boolean if true. This technique prevents the execution of the second expression if unnecessary [...]