C# articles and tutorials on SharpDeveloper.NET

Sharpen your .NET skills with our C# articles, tutorials, demos, and source code by Sameer Alibhai
posts - 63, comments - 53, trackbacks - 1

May 2007 Entries

No Silver Bullet vs. Agile Software

While there may be "no silver bullet" in software development, Agile Software methodologies provide a strong and compelling base from which to deal with the inherent complexities of software development.

posted @ Wednesday, May 30, 2007 7:32 PM | Feedback (1) | Filed Under [ Software Engineering ]

How To Isolate Code To Run only on Certain Servers

Occasionally with websites, the need arises to have a block of code that executes only on a particular set of servers--whether local development servers, or client servers, or production servers. In particular, you may find this useful if you have code you want to run only on development servers. How, then, can you accomplish this?

posted @ Tuesday, May 29, 2007 7:12 PM | Feedback (0) | Filed Under [ .NET articles ]

Use Enum (C#) instead of magic numbers

Enumerations (enums) make your code much more readable and understandable. How to use enums to enrich your code. Includes C# and VB.NET enum example

posted @ Tuesday, May 29, 2007 4:29 PM | Feedback (1) | Filed Under [ .NET articles ]

Proper Use of Static Functions

A static function is static because you do not need to create an instance of the class in order to use it. Some popular static functions are located in the Math library, for example, Math.Min(x,y). Your class or function can be static when it has no need for class or member variables, and it is also compact and stateless. Don't forget, you have to still consider thread safety!

posted @ Tuesday, May 29, 2007 4:27 PM | Feedback (0) | Filed Under [ .NET articles ]

Prefix tables with dbo. in your SQL

A power tip on increasing your query execution speed is to prefix your table and stored procedure names with dbo. By prefixing with dbo, Our database makes one less call. Normally, when you do not use the dbo keyword, on a query such as Select * from Users where UserID = @UserID, it will first check the user's schema to see if that table exists for them.

posted @ Tuesday, May 29, 2007 11:38 AM | Feedback (0) | Filed Under [ SQL ]

Visual SourceSafe 2005 Tip (VS2005) - Keywords

posted @ Tuesday, May 29, 2007 11:19 AM | Feedback (0) | Filed Under [ .NET articles Visual SourceSafe ]

HttpContext Can Break Object Oriented Principles

How incorrect use of HttpContext can break object oriented principles and how to fix it.

posted @ Tuesday, May 29, 2007 11:19 AM | Feedback (0) | Filed Under [ .NET articles ]

Successful Server Migration using the HOSTS file

What is the Windows HOSTS file, and how to use the HOSTS file to test your site before re pointing the server during a server migration to successfully ensure a seamless migration with no down time.

posted @ Tuesday, May 29, 2007 10:17 AM | Feedback (0) | Filed Under [ Hosting ]

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

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

posted @ Friday, May 25, 2007 12:35 PM | Feedback (1) | Filed Under [ .NET articles ]

Benefits of using ConnectionStrings Element Instead of AppSettings

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

posted @ Friday, May 25, 2007 9:38 AM | Feedback (0) | Filed Under [ .NET articles ]

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

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.

posted @ Friday, May 25, 2007 9:37 AM | Feedback (2) | Filed Under [ .NET articles ]

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

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.

posted @ Friday, May 25, 2007 9:37 AM | Feedback (2) | Filed Under [ .NET articles ]

Do NOT eat exceptions (C# .NET)

posted @ Friday, May 25, 2007 9:36 AM | Feedback (0) | Filed Under [ .NET articles ]

How To Properly Use ?? With Default Values

posted @ Friday, May 25, 2007 9:36 AM | Feedback (0) | Filed Under [ .NET articles ]

Creating SqlParameters Best Practices

posted @ Friday, May 25, 2007 9:35 AM | Feedback (1) | Filed Under [ .NET articles ]

Powered by: