Archive for the ‘C#’ Category

Convert String Array to Int Array and vice versa in C#

Sometimes you want to convert arrays back and forth. This is to nice extension methods to convert a int array into a string array and vice versa.
public static class ExtensionMethods {

public static string[] ToStringArray(this int[] intArray) {
return Array.ConvertAll<int, string>(intArray, delegate(int intParameter) { return intParameter.ToString(); });
}

public static [...]

file_get_contents() in asp.net/C#

The URL shortening service http://bit.ly has a really simple and convient API that lets just get a short url like this.
http://bit.ly/api?url=http://www.myreallylong.com/url/with/lots?of=crap
I’ve used this in a wordpress installation with PHP before and there i could just do.
$twitter_url .= file_get_contents(’http://bit.ly/api?url=’ . get_permalink());
Simple and clean. But today i wanted to do the same thing with asp.net and found [...]

Create a tag cloud with limited amout of tags in ASP.NET and LINQ

Today i built a Tag cloud for my new site. I found this great article about on how to do it with LINQ and C#. But i missed some features. Especially how to limit the number of tags that was shown. So if you read that article and then have a look at this code [...]