正如我已经做过的那样,我有这段代码:
private string opt;// create a property
public string optionInterval
{
get
{
return opt;
}
set
{
opt = value;
}
}
Run Code Online (Sandbox Code Playgroud)
如何将opt更改为整数?特别是在设定部分?
public int optionInterval { get; set; }
Run Code Online (Sandbox Code Playgroud)
使用自动实现的属性
private int opt;
public string optionInterval
{
get
{
return opt.ToString();
}
set
{
opt = Convert.ToInt32(value);
}
}
Run Code Online (Sandbox Code Playgroud)
private int opt;
public string optionInterval
{
get
{
return opt.ToString();
}
set
{
opt = Convert.ToInt32(value);
}
}
Run Code Online (Sandbox Code Playgroud)