3

.NET Predicates (and a .RemoveAll() example)

Posted by Sameer on May 25, 2007 in .NET articles |

What is a .NET Predicate and a C# example on how to use it.

0

Benefits of using ConnectionStrings Element Instead of AppSettings

Posted by Sameer on May 25, 2007 in .NET articles |

With .NET 2.0 we can use .ConnectionStrings, and gain 3 benefits. – We can encrypt our connection strings on the fly using reg_iis (or by other methods), We can add SQL Cache Dependencies, By putting connection strings in the right place, we can take advantage of any new features that come out that use the ConnectionStrings element

3

Use String.Format (C# and VB.NET) instead of Chopping Strings

Posted by Sameer on May 25, 2007 in .NET articles |

String.Format is just so cool. It makes your code less spaghetti like and makes it easier to replace string values or add new values. It also allows you to see from a quick glance what your code does. It also makes it MUCH easier to update your string and add more parameters to it. It works similarly to the printf function in C++ that takes a string, and then is followed by parameters that specify what to plug into the string.

2

Use TryParse instead of Throwing Exceptions (Try {} Catch {})

Posted by Sameer on May 25, 2007 in .NET articles |

Tryparse is a C# function that you can use to convert from a string to another data type such as integer. It allows you to avoid throwing exceptions and catching them. This can be a more efficient way to write your code and avoid clunky exceptions. It returns true if the conversion succeeds, so you can also use it to test if a string is numeric or not.

0

Do NOT eat exceptions (C# .NET)

Posted by Sameer on May 25, 2007 in .NET articles |

Proper exception handling is part of writing good code.  Here’s a quick tip – if you don’t want to handle an exception, fine, just leave it., don’t put any try/catch and just let the exception propogate up to it’s caller.  If you are not sure why you are using try/catch, maybe you shouldn’t be using [...]

0

How To Properly Use ?? With Default Values

Posted by Sameer on May 25, 2007 in .NET articles |

Let’s define a nullable.  You can declare a variable as nullable, for example int ? x; You are saying that the int might have a value, or it might have a null value.  This is convenient Now in your code you might want to check and see if its actually null and if it is, [...]

12

Creating SqlParameters Best Practices

Posted by Sameer on May 25, 2007 in .NET articles |

This article summarizes some nice ways to create SqlParameter arrays.  When we use SqlHelper, or even without SqlHelper when we use SqlCommands directly, and we want to pass an array of SqlParameters to the function.  The method I will discuss does not require you to hard-code the number of elements, nor does it require you [...]

Copyright © 2007-2012 SharpDeveloper now AgileChai All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.0.2, from BuyNowShop.com.