【问题标题】:public Class name[][] Method name{ get; set; } what does this mean in c#?public 类名[][] 方法名{ get;放;这在 c# 中是什么意思?
【发布时间】:2017-02-21 07:33:49
【问题描述】:

这在 c# 中是什么意思?

public Extra_Bed_Configurations[][] extra_bed_configurations { get; set; }

Extra_Bed_Configurations 类具有以下属性。

public class Extra_Bed_Configurations
{
    public string type { get; set; }
    public int code { get; set; }
    public int count { get; set; }
    public string name { get; set; }
}

【问题讨论】:

  • 删除该类类型的 Jagged array 属性。
  • 这意味着你有一个 Extra_Bed_Configurations 类的二维数组
  • What is a jagged array?的可能重复
  • 哪一部分你不明白?
  • 最直接地说:{ get; set;} 部分与您无关。 Extra_Bed_Configurations[][] 表示,该字段是 Extra_Bed_Configurations[] 类型的对象数组,它只是 Extra_Bed_Configurations 的数组。 (将来也可以使用 google 和 MSDN 文档)

标签: c# .net


【解决方案1】:

这是 锯齿状数组(数组的数组)Extra_Bed_Configurations

类型的公共属性

注意:

多维:Extra_Bed_Configurations[,] extra_bed_configurations

锯齿状:Extra_Bed_Configurations[][] extra_bed_configurations


2x2 的示例声明

extra_bed_configurations = new Extra_Bed_Configurations[][]{ 
        new Extra_Bed_Configurations[] {
            new Extra_Bed_Configurations() { type = "foo"}, 
            new Extra_Bed_Configurations() { type = "foo"}
        },
        new Extra_Bed_Configurations[] { 
            new Extra_Bed_Configurations() { type = "foo"}, 
            new Extra_Bed_Configurations() { type = "foo"}}
    };

【讨论】:

    【解决方案2】:
    • public 是访问修饰符,它不限制任何访问 财产;

    • Extra_Bed_Configurations[][]jagged array

    • extra_bed_configurations 分别是您的财产名称;

    • { get; set; } 表示此属性为auto-implemented

    【讨论】:

      【解决方案3】:

      [][] 是数组的数组。

      1 -> A B C D
      2 -> E F G H I J
      3 -> K L M 
      4 -> N O 
      

      【讨论】:

        【解决方案4】:

        {get;set} 在成员为这些类型创建 getter 和 setter 之后。 这是副本 c#: getter/setter

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-02-16
          • 1970-01-01
          • 2010-11-21
          • 2011-01-29
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多