Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Does Replace Return Nothing on Empty String

Tags:

vb.net-2010

Replace("",vbLf, "")

Go figure.

It should return ""

No. It returns nothing.

Just put the code in vb.net

I think it should return "". Replace all occurance of vbLF with "". Because the original string is "" then it simply replace nothing and we got back ""

\No. We got back nothing.

like image 338
user4951 Avatar asked Feb 28 '12 02:02

user4951


2 Answers

You are using Visual Basic string functions, not .Net. The Visual Basic runtime usually evaluates Nothing as an empty string ("").

like image 83
Kenneth Funk Avatar answered Oct 17 '22 10:10

Kenneth Funk


I second the original post, VB.net should not return NOTHING with its REPLACE function. However, it does if your replace happens to return Nothing if the expression is an empty string.

like image 27
AdamL Avatar answered Oct 17 '22 10:10

AdamL