我想將一行文本作爲字符串分配,因此可以在消息框中使用該字符串,但該字符串在執行該方法時無法顯示在消息框中。在C中獲取和設置的問題#
public string version { get; set; }
public void GetVersion()
{
var version = File.ReadAllText("version.txt");
}
private void SetBalloonTip()
{
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipTitle = "Test";
notifyIcon1.BalloonTipText = "This is version " + version;
notifyIcon1.BalloonTipIcon = ToolTipIcon.Error;
this.Click += new EventHandler(button1_Click);
}
爲什麼你會期待警告?聲明一個局部變量並將函數的返回值賦值給該變量是完全合法的。究竟是什麼會引發警告? –
@Cody當局部變量與「global」變量名稱相同時,又稱爲類成員.. –