4

我有两个类'passwordsettings'和'helper'。给出了这些类。

密码设置.cs

public class PasswordSetting
{
    public PasswordSetting()
    {

    }

    //password age , 80, 180, 360 days
    public int Duration { get; set; }

    //password minimum length
    public int MinLength { get; set; }

    //password maximum length
    public int MaxLength { get; set; }

    //password Numbers length
    public int NumsLength { get; set; }

    //password Upper letter length
    public int UpperLength { get; set; }

    //password Special character length
    public int SpecialLength { get; set; }

    //password valid special characters
    public string SpecialChars { get; set; }
}

助手.cs

public  class Helper
{
    public Helper()
    {        
         //TODO: Add constructor logic here        
    }

    public static PasswordSetting GetPasswordSetting()
    {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(HttpContext.Current.Server.MapPath("~/PasswordPolicy.xml"));

        PasswordSetting passwordSetting = new PasswordSetting();

        foreach (XmlNode node in xmlDoc.ChildNodes)
        {
            foreach (XmlNode node2 in node.ChildNodes)
            {
                passwordSetting.Duration = int.Parse(node2["duration"].InnerText);
                passwordSetting.MinLength = int.Parse(node2["minLength"].InnerText);
                passwordSetting.MaxLength = int.Parse(node2["maxLength"].InnerText);
                passwordSetting.NumsLength = int.Parse(node2["numsLength"].InnerText);
                passwordSetting.SpecialLength = int.Parse(node2["specialLength"].InnerText);
                passwordSetting.UpperLength = int.Parse(node2["upperLength"].InnerText);
                passwordSetting.SpecialChars = node2["specialChars"].InnerText;
            }
        }
        return passwordSetting;
    }
}

但是当我在按钮单击事件中使用它们时,会出现以下问题.. 为什么会发生这种情况?在此处输入图像描述

4

1 回答 1

5

由于某种原因,它看起来Helper实际上(原文如此)内的嵌套类。PasswordStreangth虽然Helper(如发布)是一个公共课程,但我的猜测PasswordStreangthinternal. 为什么是Helper嵌套类呢?

当然,这可能PasswordStreangth是您的命名空间 - 我手头没有 VS 来检查它是否会在 Intellisense 中以这种方式显示。如果是这种情况,那么大概在您正在构建的版本中实际上Helper 并未将其声明为公共 - 可能是代码中其他地方的更改,或者过时的构建?

于 2012-11-01T09:38:51.327 回答