convert vb to c#

Posts   
 
    
ksk
User
Posts: 2
Joined: 06-Sep-2008
# Posted on: 08-Oct-2008 13:34:23   

If Trim(entry.Value) = "" Then entry.Value = Nothing End If

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 08-Oct-2008 16:54:07   

ksk wrote:

If Trim(entry.Value) = "" Then entry.Value = Nothing End If

Is this a test? wink

if(entry.Value.Trim().Length<=0) { entry.Value = null; }

btw: 1) it's better not to use old VB5-6 native keywords like 'Trim'. Better use the .NET framework, so use the 'Trim' method on string 2) I personally don't think it's wise to use 'null' for string values, unless you absolutely have to.

Frans Bouma | Lead developer LLBLGen Pro
wtijsma
User
Posts: 252
Joined: 18-Apr-2006
# Posted on: 13-Nov-2008 16:33:16   

Otis wrote:

2) I personally don't think it's wise to use 'null' for string values, unless you absolutely have to.

Pff I couldn't agree more. string.Empty is the natural state of an empty string. Making System.String nullable is in my opinion the biggest mistake in the .Net framework design simple_smile

Same for people still using Guid.Empty and *.MinValue to instead of nullable types, and people that set all their database fields on nullable by default. The Horror simple_smile

  • Wiebe