Disclaimer: I was recently asked this in an interview and quickly found myself dealing with some very messy indexing syntax using arrays. I decided to revisit the problem later to see if my initial hunch of treating the uint input as a string would tend toward a cleaner solution.

/// <summary>
/// Input treated as a string for simplification 
/// </summary>
/// <param name="x"></param>
/// <returns>bool</returns>
protected bool IsPalindrome(uint x)
    string givenNum = Convert.ToString(x);
    char[] input = givenNum.ToCharArray();    

    string testString = String.Empty;
    foreach (char a in input)
        testString += a;

    return givenNum == testString;

It works fine but I still thought it was a little more verbose than it could be so I posted this question on Stack Overflow and got some very interesting responses. I eventually went with the following solution; since a uint was specifically specified as a parameter, it would seem that an interviewer would be looking for a numerical, non-string answer.

protected bool IsPalindrome(uint x)
    uint original = x;
    uint reverse = 0;

    while (x > 0)
        reverse *= 10;
        reverse += x % 10;
        x /= 10;
    return original == reverse;

Tags: ,


Azure CloudHaving spent two days trying to set up a custom URL for my Azure website, I'm sharing the configuration settings that worked for me. The existing documentation for this is seriously lacking when it comes to setting up CNAME and A record entries in our DNS admin.

After following the Microsoft documentation, I finally had my root URL working but got 404 error when trying to access my site using "www". Here's how I fixed that...

Assuming an Azure Website name is myazurewebsite and custom DNS is mywebsite.com I have one A record:

1) Host name:mywebsite.com IP: (IP taken from domain management in Azure Website)

And two CNAME records:

1) Alias:awverify.mywebsite.com points to host:awverify.myazurewebsite.azurewebsites.net
2) Alias:www.mywebsite.com points to host:myazurewebsite.azurewebsites.net

Then I have Azure Website configured with two domain names:

1) mywebsite.com
2) www.mywebsite.com

An Introduction to NuGet

by admin 9. May 2012 17:09

NuGet Package ManagerGetting started with NuGet can be very confusing because there are really four parts to it with separate downloads. This post is an effort to make it easier to grasp and get started.

NuGet is one of those tools that you may not notice at first, but once you start using it you'll wonder how you ever got by without it. Not just a package manager, it is an ecosystem, a foundation upon which many different things can be built. A NuGet package can consist of assemblies, source code, config files, images, scripts, etc.

Do yourself a big favor and grab a copy of Pro NuGet by Maarten Balliauw and Xavier Decoster. From the book: "NuGet brings you all the benefits of any package manager: it takes care of dependency chains and versioning conflicts at installation time, and it facilitates finding, installing, updating and uninstalling packages on application level. Besides these common must-have functionalities, NuGet has much more to offer."

NuGet relieves us of the following headaches when trying to incorporate a third party library into our project:

1) Locate the application

2) Download the correct version of the package

3) "Unblock" the package

4) Unzip the files into our solution

5) Add an assembly reference

6) Update Web.Config with the correct entries

With NuGet, this is all done for us with one or two clicks!


There are four main tools I use with NuGet, three by Microsoft and a third party tool called Package Explorer, created by Luan Nguyen, which I consider indispensable for routine everyday tasks.


Package Manager Console Microsoft
Use WPI*
Package Manager GUI Microsoft
Use WPI*
NuGet Command Line Tool Microsoft Download
Package Explorer Third Party Tool Download

* Web Platform Installer


1) Package Manager Console The Package Manager Console is a Visual Studio Extension that allows us to interact with NuGet from within Visual Studio using cmdlets ("commandlets") for routine operations.


Package Manager Console


2) Package Manager GUI The Package Manager GUI is a graphical user interface which allows us to visualize and edit package contents and metadata.


Package Manager GUI


3) NuGet Command Line Tool Interact with NuGet from a simple console window. Also used by CI systems and deployment environments to get or publish packages.


NuGet Command Line

4) Package Explorer NuGet Package Explorer is a ClickOnce application which allows creating and exploring NuGet packages easily. After installing it, you can double click on a .nupkg file to view the package content.


Package Explorer

More Information