关于在OOP应用程序中存储的数据

时间:2014-03-11 05:45:30

标签: c# oop

Hello OOP'ers遍布全球! 我有一个奇怪的理解oop的问题:在对话后我有一些数据,我可以用class:

来呈现这些数据
public class RegistrationBody
    {
        public string UserName { get; set; }
        public string UserSurname { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public string INN { get; set; }
        public bool AllowForSpam { get; set; }

        public RegistrationBody(string userName, string userSurname, string email, string phone, string ИНН, bool allowForSpam)
        {
            UserName = userName;
            UserSurname = userSurname;
            Email = email;
            Phone = phone;
            INN = INN;
            AllowForSpam = allowForSpam;

        }

在主窗口中,我调用表单,然后我得到类似于该结构的数据;之后我需要建立网址。 问题:我需要使用哪个类来构建url并将其存储到应用程序关闭之前?据我所知,我需要避免主类中的公共变量,所以我需要构建什么?

2 个答案:

答案 0 :(得分:0)

要构建网址,您可以使用 NameValueCollection

您可以将其存储在任何持久存储中或缓存它。

答案 1 :(得分:0)

对于主类,使用私有方法并调用将公开的类,该类的页面加载将是私有的。例如,取这个senario:

从按钮单击,您正在调用RegistrationBody类,因此在主类中按钮单击将是私有的

  

private void btnbutton_Click(object sender,EventArgs e){/ *你的   代码* /

     

}

RegistrationBody类中的

将是公共的,你可以提到这个类的页面加载到私有depand的要求

  

private void RegistrationBody_Load(object sender,EventArgs e)           {}