获取 set 属性作为 bool[] 返回

发布于 2024-09-14 16:11:00 字数 1024 浏览 3 评论 0原文

这是一个非常基本的问题。

void Output(int output); ->这会启用一个输出

bool[] Outputs { get;放; } ->这可以实现多重输出。我需要这个的实施。这是一个声明为接口的 API。

在我的课堂上我需要使用它。

我研究了这个http://msdn.microsoft.com /en-us/library/87d83y5b%28VS.80%29.aspx...但是我没有在哪里获得获取和设置返回布尔数组的参考。

在上面的链接中,类为:

interface IPoint { // 属性签名: 整数x { 得到; 放; } 整数 { 得到; 放; } ?

class Point : IPoint
{
   // Fields:
   private int _x;
   private int _y;

   // Constructor:
   public Point(int x, int y)
   {
      _x = x;
      _y = y;
   }

   // Property implementation:
   public int x
   {
      get
      {
         return _x;
      }    
      set
      {
         _x = value;
      }
   }

   public int y
   {
      get
      {
         return _y;
      }
      set
      {
         _y = value;
      }
   }
}

在我的例子中,类声明是什么

This is a very basic question.

void Output(int output); -> this enables one single output

bool[] Outputs { get; set; } -> This enables multiple output. I need the implementation of this. This is an API declared as a interface.

In my class I need to use it.

i studied this http://msdn.microsoft.com/en-us/library/87d83y5b%28VS.80%29.aspx... but no where I got reference to get and set returning a bool array.

In the above link, the class is as:

interface IPoint
{
// Property signatures:
int x
{
get;
set;
}
int y
{
get;
set;
}
}

class Point : IPoint
{
   // Fields:
   private int _x;
   private int _y;

   // Constructor:
   public Point(int x, int y)
   {
      _x = x;
      _y = y;
   }

   // Property implementation:
   public int x
   {
      get
      {
         return _x;
      }    
      set
      {
         _x = value;
      }
   }

   public int y
   {
      get
      {
         return _y;
      }
      set
      {
         _y = value;
      }
   }
}

what will be the class declaration in my case ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘亓 2024-09-21 16:11:00
public bool[] Outputs {get; set;} 

将创建一个名为“Outputs”的属性,返回 bool 数组。这是一个快捷语法,如果您想使用更长的语法,那么它会像这样

private bool[] _outputs;
public bool[] Outputs
{
   get
    {
      return _outputs;
    }
   set
    {
      _outputs = value;
    }
}
public bool[] Outputs {get; set;} 

will create a property named "Outputs" returning bool array. This is a shortcut syntax, if you wish to use longer syntax then it would go some thing like

private bool[] _outputs;
public bool[] Outputs
{
   get
    {
      return _outputs;
    }
   set
    {
      _outputs = value;
    }
}
你与清晨阳光 2024-09-21 16:11:00

它与 MSDN 上的示例相同,但将“int”替换为“bool[]”。

It's the same as the sample on MSDN, but replace "int" with "bool[]".

我ぃ本無心為│何有愛 2024-09-21 16:11:00

这是一个示例实现:

public class YourAPIImpl: IYourAPI
{
    public bool[] Outputs { get; set; }

    public void Output(int output)
    {
        throw new NotImplementedException();
    }
}

Here's a sample implementation:

public class YourAPIImpl: IYourAPI
{
    public bool[] Outputs { get; set; }

    public void Output(int output)
    {
        throw new NotImplementedException();
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文