Home > Software engineering >  Trim (txtUserName. Text="") and Trim (txtUserName. Text)=" "is there a differenc
Trim (txtUserName. Text="") and Trim (txtUserName. Text)=" "is there a differenc

Time:10-31

Trim (txtUserName Text="") this is as a student management system source code, the Trim (txtUserName. Text=" ") and Trim (txtUserName. Text)="" is there a difference? The former is correct?

CodePudding user response:

Trim (txtUserName. Text="") is not reasonable, should be not correct,

CodePudding user response:

Well, because of the implicit type conversion, grammar, but clearly write wrong,

CodePudding user response:

Should be written on the Trim (txtUserName. Text)="", the Trim () function is clear space function, namely the txtUserName. The Text of the Spaces before and after take out,

CodePudding user response:

reference photel123456 reply: 3/f
should be written in the Trim (txtUserName. Text)="", the Trim () function is clear space function, namely the txtUserName. The Text of space before and after remove,

I think so

CodePudding user response:

This code is really rubbish,

CodePudding user response:

Both writing no problem.
There is a difference between both
Only the first writing Trim is meaningless, redundant
The first can be judged whether the characters in the txtUserName empty
The second can be judged whether txtUserName character is empty or only include the space character

CodePudding user response:

Trim (txtUserName. Text="")

(txtUserName. Text="") returns a Boolean value: True or false
Then on the logical value space cut?

The code has a lot of sense.
  • Related