Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I check if variable is empty
Message
 
 
To
06/08/2008 02:04:28
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01336718
Message ID:
01336850
Views:
12
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform