Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I check if variable is empty
Message
 
 
À
06/08/2008 02:04:28
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01336718
Message ID:
01336850
Vues:
11
>>Hi everybody,
>>
>>I have a property declared as byte[]. I'm getting it from SQL Server database (varbinary(max)). I'm selecting it like this
>>
>>select ISNULL(DefaultPicture,'') as DefaultPicture
>>
>>In my C# code I need to check if the value is empty. What should I do?
>>
>>Thanks in advance.
>
>
>Since it's declared as byte[] which is an array,
>
>bool empty = (DefaultPicture.Length == 0)
>
>
>
>Had it been declared as string
>
>bool empty = String.IsNullOrEmpty(DefaultPicture)
>
BTW, if I would have declared it as a string (thus avoiding the null problem), how would I be able to convert it to byte array? I don't think string would have worked for the picture...
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform