D
Dim
I found that C# has some buggy ways to process string across methods.
I have a class with on global string var and a method where i add / remove
from this string
Consider it a buffer... with some values and separators
class
{
private string globalvar = "";
private void manipulate (whattodo ) //substring, join, etc....
{
some manipulation on globalvar...
some join here
some substring-ing here
etc...
}
}
After couple calls to this method my global string must contain "" since it
has been processed
and all data from it have been extraced by that method and passed to another
methods, since this global var is a buffer....
I expect it to contain nothing but "" empty zero lentgh string, but it
doesn't
Apparently when u manipulate string and Join, Substring Replace etc. in it
it does nothing else bu t GROVING and groving. After a couple of this
operations i converted this string to char array and
displayed it's size. Debugger shows med an empty string , but char array
size wasmore than 1000....
and none of comparison methods (mystring == "") or (mystring.Equals("")
worked :-(
After some close examination i discovered that that char array i converted
my "empty" string to
contains nothing but 0x0 chars :-( HOW CAN IT CONTAIN null chars... ??????
I even tried to pass values through different objects (Huh? why.. dunno)
string ttt = Slices.Substring(Slices.IndexOf("|",0)+1);
Slices = "";
Slices = ttt;
This approach didn't work eighter...
Anyway to solve this and to make my comparison work when buffer string was
"" I had to add
..Replace("\0", "") to every manipulation of my buffer string...
Ex.
Slices = Slices.Substring(Slices.IndexOf("|",0)+1)
Becomes
Slices = Slices.Substring(Slices.IndexOf("|",0)+1).Replace("\0", "");
Thas seems to solve this problem, but i'm still wondering where this
behavior comes from???
Poor language engineering??? ,, Bug???,,, or am i just stupid?
I have a class with on global string var and a method where i add / remove
from this string
Consider it a buffer... with some values and separators
class
{
private string globalvar = "";
private void manipulate (whattodo ) //substring, join, etc....
{
some manipulation on globalvar...
some join here
some substring-ing here
etc...
}
}
After couple calls to this method my global string must contain "" since it
has been processed
and all data from it have been extraced by that method and passed to another
methods, since this global var is a buffer....
I expect it to contain nothing but "" empty zero lentgh string, but it
doesn't
Apparently when u manipulate string and Join, Substring Replace etc. in it
it does nothing else bu t GROVING and groving. After a couple of this
operations i converted this string to char array and
displayed it's size. Debugger shows med an empty string , but char array
size wasmore than 1000....
and none of comparison methods (mystring == "") or (mystring.Equals("")
worked :-(
After some close examination i discovered that that char array i converted
my "empty" string to
contains nothing but 0x0 chars :-( HOW CAN IT CONTAIN null chars... ??????
I even tried to pass values through different objects (Huh? why.. dunno)
string ttt = Slices.Substring(Slices.IndexOf("|",0)+1);
Slices = "";
Slices = ttt;
This approach didn't work eighter...
Anyway to solve this and to make my comparison work when buffer string was
"" I had to add
..Replace("\0", "") to every manipulation of my buffer string...
Ex.
Slices = Slices.Substring(Slices.IndexOf("|",0)+1)
Becomes
Slices = Slices.Substring(Slices.IndexOf("|",0)+1).Replace("\0", "");
Thas seems to solve this problem, but i'm still wondering where this
behavior comes from???
Poor language engineering??? ,, Bug???,,, or am i just stupid?