Posts Tagged ‘C#’

Create a comma separated list with LINQ in C#

For some reason I always forget that you do not do .Join on your actual string array. So i might as well write it down here so i never forget about this again. string mycommalist = string.Join(“,”, alternatives.Select(x=>x.Item.Name).ToArray())

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 int[] ToIntArray(this string[] strArray) [...]

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 [...]

Group By with LINQ

Today i wanted to do a group by query with LINQ wich is something i never done before. I turned out to be kind of easy. If you just want to group by a single field. (from s in db.CrewStatsSet where s.LogDate &gt;= date1 &amp;&amp; s.LogDate &lt;= date2 &amp;&amp; s.Action == action group s by [...]

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 [...]

Using JQuery Validation plugin with ASP.NET

Like everyone else i’ve been playing around with JQuery alot latley. Asp.net and JQuery is not the best friends in the world but i guess it will be alot better when using ASP.NET MVC. Microsoft also annoncued that they will support JQuery natively in future versions. Nice! If you want to learn more about ASP.NET [...]