Feb 24

Please check out C# 411, a new blog from the author of DevTopics that focuses on the C# programming language and .NET Framework and is full of C# information, news, tips and code.

C# 411

Feb 11

Given a string ’s’, which of the following expressions is faster?

1.  String.IsNullOrEmpty( s )
 
2.  s == null || s.Length == 0

 

Continue reading »

Feb 05

Here is a collection of puns that only a C# programmer could appreciate:

Nerds

Continue reading »

Feb 04

If you need a collection of objects accessed by a key, and the key is one of the object’s properties, then you should use the KeyedCollection class instead of Dictionary.  For example, you would use a KeyedCollection to store Employee objects accessed by the employee’s ID property.

Continue reading »

Jan 24

When building your first .NET web service, you may be in for a rude awakening when you discover the concept of “partial trust.”  Your previously bullet-proof code will suddenly fail in a flurry of exceptions thrown by seemingly innocuous commands such as reading files or accessing the Registry.  This article provides a brief overview of Code Access Security and describes how to modify and test your code to work in a partial trust environment.
 

Continue reading »

Jan 21

Creating C# objects at run-time is easy.  Just call the Activator.CreateInstance method.

For example, to create the same type of object as the current object using its default constructor:

Activator.CreateInstance( this.GetType() );  

Continue reading »

Jan 18

Recently I posted a list of the Best C# Blogs.  Today we recognize the best C# Web sites.

Following (in alphabetical order) are the best C# sites active on the Web today.  Also included is the “About” section of the site (edited for space and clarity).  Please comment if you can recommend other excellent C# web sites that didn’t make my list.

Continue reading »

Tags:

Jan 16

Sometimes you need to be able to convert between multiple data types.  One solution is to create a “universal type converter,” which is an object that implicitly executes all of the desired type conversions.

Continue reading »

Jan 11

This blog is usually a place for answers, but today I have a web service question that has stumped me and the experts I’ve consulted thus far.  Here is my challenge:

When a client connects to a C# web service, how can it bind to a specific DLL in the web service “bin” folder?

Continue reading »

Jan 08

Reflection is a handy mechanism in .NET that enables you to obtain class information, get and set properties, and invoke methods entirely at run-time.  Reflection can also provide information about the object and method that called a particular method.  This can be useful for debug and trace purposes.

Continue reading »