嗨什么是JAVA等同于用C#class 1编写的代码的和平:
public string Password
{
get { return password; }
set { password = value; }
}
Run Code Online (Sandbox Code Playgroud)
第2课:
try
{
UserEntity user = new UserEntity();
user.Password = textBoxPassword.Text;
user.InsertUser();
MessageBox.Show("User is registred");
}
Run Code Online (Sandbox Code Playgroud)
在java中我写了这个:class 1:
protected int password ;
public int getPassword(){
return password;
}
public void setPassword(int password){
this.password=password;
}
Run Code Online (Sandbox Code Playgroud)
class2:
LoginEntity login = new LoginEntity();
login.getPassword() = pwdTextBox.getText();// here ERROR : required variable , found value
Run Code Online (Sandbox Code Playgroud)
既不是C#也不是Java,你可以在赋值的左侧进行方法调用.所以这:
login.getPassword() = pwdTextBox.getText();
Run Code Online (Sandbox Code Playgroud)
在Java或C#中无效
也许你想要
login.setPassword(pwdTextBox.getText());
Run Code Online (Sandbox Code Playgroud)
虽然你真的应该避免使用字符串密码,因为它们很容易被嗅到,使你的密码保护很差.
| 归档时间: |
|
| 查看次数: |
247 次 |
| 最近记录: |