本文介绍了类包含私有构造函数和公共属性,那么我们如何在C#中分配公共属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公共课mUIPassword

{

public mUserPasswords user {get;组; }

公共字符串频道{get;组; }

public string lang {get;组; }

mUIPassword()

{

channel =device | Web;

lang =en ;

}

}

公共类mUserPasswords

{

public string newPassword {get;组; }

public string oldPassword {get;组; }

}



我的尝试:



这里我如何分配用户属性?

public class mUIPassword
{
public mUserPasswords user { get; set; }
public string channel { get; set; }
public string lang { get; set; }
mUIPassword()
{
channel = "device|Web";
lang = "en";
}
}
public class mUserPasswords
{
public string newPassword { get; set; }
public string oldPassword { get; set; }
}

What I have tried:

Here how can I assign user property?

推荐答案

public class mUIPassword
    {
    public mUserPasswords user { get; set; }
    public string channel { get; set; }
    public string lang { get; set; }
    private mUIPassword()
        {
        channel = "device|Web";
        lang = "en";
        }
    private static mUIPassword theInstance = null;
    public static mUIPassword GetInstance()
        {
        if (theInstance == null) theInstance = new mUIPassword();
        return theInstance;
        }
    }


这篇关于类包含私有构造函数和公共属性,那么我们如何在C#中分配公共属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 12:01