C# 为什么类类型在方法调用中具有数组符号
我有一个返回一些值的方法,其类型为C# 为什么类类型在方法调用中具有数组符号,c#,C#,我有一个返回一些值的方法,其类型为AppPints(),如下所示 public AppPints[] GeByLatLong(int scale) { return GeByLatLong(scale); } 但是你能告诉我为什么它在方法定义中有[]符号吗?为什么不 public AppPints GeByLatLong(int scale) { return GeByLatLong(sca
AppPints()
,如下所示
public AppPints[] GeByLatLong(int scale)
{
return GeByLatLong(scale);
}
但是你能告诉我为什么它在方法定义中有[]
符号吗?为什么不
public AppPints GeByLatLong(int scale)
{
return GeByLatLong(scale);
}
您的方法正在返回一个
AppPints的数组
第一个方法返回一个AppPints的数组
(例如0..*),而另一个方法只返回一个(但是可能是null
)。既然您似乎知道[]
表示一个数组,那么问题是什么?返回类型声明有一个数组符号,因为该方法返回一个数组。因为该方法返回一个AppPints对象数组。