Tagc#

Why Are Interfaces Useful?

W

Interfaces, usually prefixed by “I” are useful in software engineering, for a number of reasons. Primarily, they allow you to create “pluggable” code. By this, I mean that your code is easier to manage, easier to maintain, easier to change the way certain parts of your application work, without changing the entire way it works. Lets look at an example. Our application is an photo sharing web...

Specify XML-RPC Endpoints at Run Time With CookComputing XMLRPC.net

S

A common question when using Cook Computing XML RPC.net to talk to blogs etc… is how to specify a blog / endpoint at runtime? Most of the examples seem to specify the details in an attribute… not much use if you’re trying to develop a wrapper. To enable me to create JoeBlogs, I made use of the IXmlRpcProxy Proxy classes… I created my interface, implementing IXmlRpcProxy: We define the method as...

C# WordPress Wrapper

C

Ok, I’ve barely finished this as a stable release, but I thought I’d post this up any way…. A little open source project I’m working on – Joe Blogs. In a nutshell, it allows easy communication to your WordPress (or other blog) via an xml-rpc interface. Big thanks to the work by Charles Cook at Joe Blogs is currently hosted on CodePlex – I’ll be posting more info, tutorials, documentation...

String.EndsWithAny and StartsWithAny Extension Method

S

It frustrated me that while String provides the StartsWith and EndWith method, it doesn’t provide an EndWithAny. So, if I wanted to see if a particular string started or ended with any specified string, I would have to create my own method to return a true or false. Whilst this is fine, it’s a little clunky if I want to use it in various places in my application. For this reason, I...

Currency Display In C#

C

In classic ASP we had FormatCurrency to take a value (number) and display it as a formatted currency. In C#, how do we achieve the same? To map a SQL 205 Money datatype to a C# class property, I use Decimal Data Type – which gives you the precision you need. A simple .ToString() on this, would display just that – the decimal, as a string. But what if you want to display a price...