Re: Checking for A Blank String
- From: "Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx>
- Date: Sun, 11 Mar 2007 02:06:38 +0100
Göran,
"Göran Andersson" <guffa@xxxxxxxxx> schrieb:
Perhaps, but the "almost" is the reason I choose to use it over the other methods.
Why not use String.IsNullOrEmpty()? That is even more specialised for this situation.
Unfortunately this method will throw exceptions in certain scenarios
Can you give one single example where it would throw an exception?
Here is a real-world sample:
\\\
Public Module Program
Public Sub Main()
Dim f As New Foo()
f.Test = Nothing
End Sub
End Module
Public Class Foo
Private m_Test As String
Public Property Test() As String
Get
Return m_Test
End Get
Set(ByVal Value As String)
If String.IsNullOrEmpty(Value) Then
Throw _
New ArgumentNullException( _
"The 'Value' must not be 'Nothing' or an empty string." _
)
End If
m_Test = Value
End Set
End Property
End Class
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
.
- Follow-Ups:
- Re: Checking for A Blank String
- From: Stephany Young
- Re: Checking for A Blank String
- References:
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: \(O\)enone
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: \(O\)enone
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- Prev by Date: Re: Checking for A Blank String
- Next by Date: Re: Checking for A Blank String
- Previous by thread: Re: Checking for A Blank String
- Next by thread: Re: Checking for A Blank String
- Index(es):
Relevant Pages
|