.Net

Converting a binary string representation into binary array in C#

Stumbled across this question on StackOverflow the other day, definitely one for the interview! The question goes: How do you convert a string such as “01110100011001010111001101110100” to a byte array then used File.WriteAllBytes such that the exact binary string is the binary of the file. In this case it would be the the text “test”. …

Converting a binary string representation into binary array in C# Read More »

WCF – Be ware of the field ordering when using DataContractSerializer

One of the less known aspect of the DataContractSerializer is its dependency on the order in which fields are serialized and deserialized. As this article points out, the basic rules for ordering include: If a data contract type is a part of an inheritance hierarchy, data members of its base types are always first in …

WCF – Be ware of the field ordering when using DataContractSerializer Read More »

Enumerable.Append and Enumerable.Prepend extension methods

Another gem I found on StackOverflow today (I’ve been spending a lot of time there these last couple of days..), this time in the form of a question on how to append or prepend a single value to an IEnumerable<T>. Greg provided an elegant solution to this particular problem, and here’s his answer: Which you …

Enumerable.Append and Enumerable.Prepend extension methods Read More »

.Net Tips – Restricting attribute usage to specific type

Before you get your hopes up, sorry, there’s no built-in support to allow you to restrict the usage of your attribute to a type easily. That’s not to say that it’s impossible though! If you’re reading this, I assume that you’ve tried to write a custom attribute yourself and realised that the options available in …

.Net Tips – Restricting attribute usage to specific type Read More »

.Net Tips – Finding the time in a given TimeZone

You can find the current time in a different time zone using the TimeZoneInfo class. To find all the available system time zones: From the returned values you can see the So, if I want to find out what the time is in Amsterdam: I can do this to get the time in HH:mm:ss format:

WCF – Data Contract version round-tripping using IExtensibleDataObject

With WCF, provided that you’re using the DataContractSerializer and not the NetDataContractSerializer, you have a certain degree of protection against data contract changes from the client’s perspective. Existing contracts will still work if existing members are not removed from the data contract, which means you are free to add new members to the data contract …

WCF – Data Contract version round-tripping using IExtensibleDataObject Read More »

WCF – Using the NetDataContractSerializer to share your type

DataContractSerializer For those of your who are familiar with WCF you would no doubt know about the DataContractSerializer class, the DataContractSerializer does not include the CLR type information in the serialized XML, which allows for loose coupling between the client and server because they don’t have to share the same CLR types. However, this also …

WCF – Using the NetDataContractSerializer to share your type Read More »

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close