Lars Holm Jensen's Code Blog

Just another WordPress codeblog on C#, Silverlight and all things .NET

C# string to alphanumeric

with one comment

Short and easy way to get the alphanumeric content of a string:

public static string ToAlphaNumeric(this string str)
{
    return new string(str.Where(c => char.IsLetterOrDigit(c)).ToArray());
}

Written by larsholm

June 16th, 2011 at 9:32 pm

Posted in .NET

Tagged with , , , ,

One Response to 'C# string to alphanumeric'

Subscribe to comments with RSS or TrackBack to 'C# string to alphanumeric'.

  1. I realise now that it might be bad practice to rely on the order in which Where returns items.

    larsholm

    25 Jan 13 at 2:40 pm

Leave a Reply

Spam Protection by WP-SpamFree