public class StudentInfo
{
public static StudentInfo studentLazy = new Lazy<StudentInfo>(() => new StudentInfo()).Value;
public int StudentID{ get; set; }
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
StudentInfo.studentLazy.StudentID = 999;
}
private void Button1_Click(object sender, RoutedEventArgs e)
{
var test = StudentInfo.studentLazy.StudentID;
}
}
标签:Lazy,StudentID,private,用法,StudentInfo,studentLazy,public
From: https://www.cnblogs.com/NingNingG/p/17162940.html