Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 显示自定义对象的常量,类似于MessageBoxButtons_C#_Visual Studio 2012_Intellisense - Fatal编程技术网

C# 显示自定义对象的常量,类似于MessageBoxButtons

C# 显示自定义对象的常量,类似于MessageBoxButtons,c#,visual-studio-2012,intellisense,C#,Visual Studio 2012,Intellisense,好的,所以我有一个奇怪的问题-我不确定我的措辞是否正确,这可能就是为什么我在搜索中没有找到任何关于这个的信息 我有一个类定义了一个主机对象,它表示一台计算机,并记录了有关该计算机的各种信息 public sealed class Host { public Host(string sName, IPAddress sAddress, string sType, string osName, bool sFirewall) { Name = sName;

好的,所以我有一个奇怪的问题-我不确定我的措辞是否正确,这可能就是为什么我在搜索中没有找到任何关于这个的信息

我有一个类定义了一个主机对象,它表示一台计算机,并记录了有关该计算机的各种信息

public sealed class Host
{
    public Host(string sName, IPAddress sAddress, string sType, string osName, bool sFirewall)
    {
        Name = sName;
        Address = sAddress;
        Type = sType;
        FirewallActive = sFirewall;
        OperatingSystem = osName;
    }

    public Host()
    {
        Name = "New Host";
        Address = IPAddress.Parse("127.0.0.1");
        Type = HostType.Desktop;
        OperatingSystem = HostOS.Win7;
        FirewallActive = true;
    }

    /// <summary>
    /// The name of the host
    /// </summary>
    public string Name { get; private set; }

    /// <summary>
    /// The ip address of the host
    /// </summary>
    public IPAddress Address { get; private set; }

    /// <summary>
    /// The type of the host
    /// </summary>
    public string Type { get; private set; }

    /// <summary>
    /// The operating system the system uses
    /// </summary>
    public string OperatingSystem { get; private set; }

    /// <summary>
    /// Whether the system has a firewall enabled
    /// </summary>
    public bool FirewallActive { get; private set; }
}
当我创建一个新的主机对象时,我希望Intellisense在构建一个新的主机([parameters])对象时,当我到达该部分时,自动提示输入一个“HostOS”变量,类似于使用MessageBox.Show(…)当您进入参数列表的该部分时,它会自动建议各种MessageBoxButtons选项的列表


与中一样,我不想修改列表-我只想Intellisense向我显示一个选项列表,这些选项是各种HostOS常量字符串。

您应该将其定义为枚举而不是类

例如:

public enum HostType
{
  Desktop,
  Server,
  Laptop
}
在类host中,必须将属性类型定义为HostType

public HostType Type { get; private set }
public HostType Type { get; private set }