本文介绍了类接口属性错误:-field never assigned,并且始终包含默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i添加新界面时出现警告错误

ie

字段sbj_p永远不会分配给,并且将始终具有其字符串的默认值。



Hi,

i am getting warning error on adding new interfaces
i.e.
Field sbj_p is never assigned to ,and will always have its default value for string.

public interface interf
    {
        String Sbj { get; set; }
        
    }
    public class login : interf
    {
        private String sbj_p;
        
        
        public string Sbj
        {
            get
            {
                return sbj_p;
            }
            set
            {
                value = sbj_p;
            }
        }
}





我尝试了什么:



它正在为其他接口工作。在添加一些新接口时,它会抛出此警告。由于这个原因,它获取的默认值为NULL,而不是取我试图通过textbox.text传递的值。



请帮助我



感谢提前



What I have tried:

Its working for other interface.On Adding some new interfaces, it is throwing this warning. Due to this ,it is getting the default value of NULL and not taking the value that i am trying to passe it through textbox.text

Please help me out

thanks in Advance

推荐答案

set
{
    value = sbj_p;
}





应该是





should be

set
{
    sbj_p = value;
}





您还可以删除私有sbj_p变量并使用此





You can also delete the private sbj_p variable and just use this

public string Sbj { get; set; }


这篇关于类接口属性错误:-field never assigned,并且始终包含默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:39