I encountered something today in C# that I’ve never seen before and it caught me off guard.  In looking at the WSE 2.0 samples to understand how the transport mechanisms have changed, I came across the following in StockService:

Uri uri = new Uri("soap.tcp://" + System.Net.Dns.GetHostName() + "/StockService");

SoapReceivers.Add( uri, typeof(StockServiceRequestReceiver) );

You’re probably wondering, “What’s the big deal, Hambone?”  On the surface, this doesn’t seem so odd until you look at the method signature for SoapReceivers.Add:

public static void Add(EndpointReference, SoapReceiver);

public static void Add(EndpointReference, Type);

public static void Add(EndpointReference, SoapReceiver, bool);

public static void Add(EndpointReference, Type, bool);

Nowhere does SoapReceiers.Add take a System.Uri, yet that’s what’s being passed in above.  What makes this possible is an implicit operator on EndpointReference that takes a Uri:

public static implicit operator EndpointReference(Uri uri)

{

      return new EndpointRefernece(uri);

}

I hate to admit that I was responsible for conducting a number of classes internally on C# and a) never brought this up and b) it was never mentioned.  In fact, this is the first time I’ve actually seen this in use.  I’m interested in your feedback … how many of you use this C# feature in your development, and to what effect?