日期:2014-05-17  浏览次数:20844 次

wpf中类不能实例化。
public class Uesr
        {

            string name;
            string password;
            string sex;
            string question;
            string answer;
            string realname;
            string age;
            string tel;
            public void showuser()
            {
                 MessageBox.Show("昵称:" +name+ "\r\n"
                              + "密码:" + password + "\r\n"
                              + "性别:" + sex + "\r\n"
                              + "密保问题:" + question + "\r\n"
                              + "密保答案:" + answer + "\r\n"
                              + "真实姓名:" + realname + "\r\n"
                              + "年龄:" + age + "\r\n"
                              + "手机号码:" + tel + "\r\n");
               
            }
        
        }

我希望在一个事件中实例化类并引用showuser()方法。请问怎么弄?
实例 wpf

------解决方案--------------------
直接在你的事件里面写就是了
User u=new User();
u.showuser();