Tag Archives: .NET

C# development with Mono and MonoDevelop

7 May

In the past two years, I have been developing .NET from my MacBook by running Windows XP into VM Ware and more recently into Virtual Box from OS X. This way, I could install Visual Studio and be able to work seamlessly.

But, this way of working has a major down side: it kills the battery of my laptop… I can easiely last for 3 hours if I stay in OS X, but can only last 45 min when XP is running.

Recently, I gave MonoDevelop a try for developing Developer IT‘s tools and web site. While being way less complete then Visual Studio, it provides essentials tools when it comes to developping software. It works well with solutions and projects files created from Visual Studio, it has Intellisence (word completion), it can compile your code and can even target your .NET app to linux or unix. This tools can save me a lot of time and batteries!

Although I could not only work with MonoDevelop, I find it way better than a simple text editor like Smultron. Thanks to Novell, we can now bring Microsoft technology to OS X.

Advertisement

How to obtain a random sub-datatable from another data table

13 Mar

Introduction

In this article, I’ll show how to get a random subset of data from a DataTable. This is useful when you already have queries that are filtered correctly but returns all the rows.

Analysis

I came across this situation when I wanted to display a random tag cloud. I already had the query to get the keywords ordered by number of clicks and I wanted to created a tag cloud. Tags that are the most popular should have more chance to get picked and should be displayed larger than less popular ones.

Implementation

In this code snippet, there is everything you need.
See the full source code here at http://www.developerit.com/2010/03/16/how-to-obtain-a-random-sub-datatable-from-another-data-table

Pro’s

This method is good because it doesn’t require much work to get it work fast. It is a good concept when you are working with small tables, let says less than 100 records.

Con’s

If you have more than 100 records, out of memory exception may occur since we are coping and duplicating rows. I would consider using a stored procedure instead.

Published on http://www.developerit.com/

Remove accents from String .NET

12 Mar

Private Const ACCENT As String = “ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÌÍÎÏìíîïÙÚÛÜùúûüÿÑñÇç”
Private Const SANSACCENT As String = “AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc”
Public Shared Function FormatForUrl(ByVal uriBase As String) As String
If String.IsNullOrEmpty(uriBase) Then
Return uriBase
End If

‘// Declaration de variables

Dim chaine As String = uriBase.Trim.Replace(” “, “-“)

chaine = chaine.Replace(” “c, “-“c)

chaine = chaine.Replace(“–“, “-“)

chaine = chaine.Replace(“‘”c, String.Empty)

chaine = chaine.Replace(“?”c, String.Empty)

chaine = chaine.Replace(“#”c, String.Empty)

chaine = chaine.Replace(“:”c, String.Empty)

chaine = chaine.Replace(“;”c, String.Empty)

‘// Conversion des chaines en tableaux de caractŠres

Dim tableauSansAccent As Char() = SANSACCENT.ToCharArray

Dim tableauAccent As Char() = ACCENT.ToCharArray

‘// Pour chaque accent

For i As Integer = 0 To ACCENT.Length – 1

‘ // Remplacement de l’accent par son ‚quivalent sans accent dans la chaŒne de caractŠres

chaine = chaine.Replace(tableauAccent(i).ToString(), tableauSansAccent(i).ToString())

Next

‘// Retour du resultat

Return chaine

End Function


Published at http://www.developerit.com/2010/03/16/remove-accents-from-string-net from http://www.developerit.com/