bitpie官方下载中文版|ca1819
CA1819 (CCA1819) 中国国际航空公司 航班跟踪和历史数据 - FlightAware
CA1819 (CCA1819) 中国国际航空公司 航班跟踪和历史数据 - FlightAware
产品
数据产品
AeroAPI
可按需提供飞行状态和航班跟踪数据的航班数据API。
FlightAware Firehose
专为企业集成而开发的实时、历史和预测性航班数据流式馈送。
FlightAware Foresight
Predictive technology to strengthen customer trust in your operations
Rapid Reports
快速购买并通过电子邮件接收历史报告。
Custom Reports
咨询性定制详细航班跟踪数据报告。
Integrated Mapping Solutions
Incorporate FlightAware maps in your web and mobile applications
应用程序
FlightAware Aviator
适合小型飞机/通用航空(GA)机主和运营商的终极飞行跟踪套件。
Premium Subscriptions
个性化的航班跟踪体验,享有无限数量的提醒及其他优势。
FlightAware Global
为公务航空(BA)机主和运营商提供的行业标准飞行跟踪平台。
FlightAware FBO Toolbox
全面的航班跟踪,帮助提升FBO运营水平,促进销售。
FlightAware TV
适合运营商或FBO的全屏FlightAware TV地图。
GlobalBeacon
为航空公司和飞机运营商提供的符合GADSS标准的全球跟踪和警报。
行业
航空公司
机场
空中交通管制
机主和运营商
政府
ADS-B
统计
SkyAware Anywhere
覆盖图
ADS-B Store
构建PiAware ADS-B接收设备
FlightFeeder
常见问题
航班跟踪
延误和取消
取消
机场延误
MiseryMap
搜索航班
航班搜索
按营运公司浏览
按机场浏览
按机型浏览
其他
随机机场
随机航班
IFR航线分析器
社区
照片
热门照片
最新照片
排名最高
编辑推荐
最新评论
社区标签
上传您的照片
新闻
时事新闻
近期新闻
热点新闻
论坛讨论
所有讨论
公司
关于
职位招聘
数据源
历史
管理团队
博客
技术博客
新闻中心
网络讲座
Advertise With Us
常见问题
联系我们
创建FlightAware帐户
或登录已有帐户
获取FlightAware应用,在您的设备上获得最佳航班跟踪体验。
加入FlightAware 登录04:39 EST
العربية
Čeština
Deutsch
English (Australia)
English (Canada)
English (UK)
English (USA)
Español (España)
Español
Suomi
Français (Canada)
Français (France)
עִבְרִית
हिन्दी
Hrvatski
Italiano
日本語
한국어
Polski
Português (Brasil)
Português (Portugal)
Русский
Türkçe
中文(简体)
中文(香港)
中文(台灣)
全部全部航线商业航班私人飞行(注册号)机场 注册
产品
数据产品
AeroAPI
可按需提供飞行状态和航班跟踪数据的航班数据API。
FlightAware Firehose
专为企业集成而开发的实时、历史和预测性航班数据流式馈送。
FlightAware Foresight
Predictive technology to strengthen customer trust in your operations
Rapid Reports
快速购买并通过电子邮件接收历史报告。
Custom Reports
咨询性定制详细航班跟踪数据报告。
Integrated Mapping Solutions
Incorporate FlightAware maps in your web and mobile applications
应用程序
FlightAware Aviator
适合小型飞机/通用航空(GA)机主和运营商的终极飞行跟踪套件。
Premium Subscriptions
个性化的航班跟踪体验,享有无限数量的提醒及其他优势。
FlightAware Global
为公务航空(BA)机主和运营商提供的行业标准飞行跟踪平台。
FlightAware FBO Toolbox
全面的航班跟踪,帮助提升FBO运营水平,促进销售。
FlightAware TV
适合运营商或FBO的全屏FlightAware TV地图。
GlobalBeacon
为航空公司和飞机运营商提供的符合GADSS标准的全球跟踪和警报。
行业
航空公司
机场
空中交通管制
机主和运营商
政府
ADS-B
统计
SkyAware Anywhere
覆盖图
ADS-B Store
构建PiAware ADS-B接收设备
FlightFeeder
常见问题
航班跟踪
延误和取消
取消
机场延误
MiseryMap
搜索航班
航班搜索
按营运公司浏览
按机场浏览
按机型浏览
其他
随机机场
随机航班
IFR航线分析器
现在就下载Flightaware应用。
社区
照片
热门照片
最新照片
排名最高
编辑推荐
最新评论
社区标签
上传您的照片
新闻
时事新闻
近期新闻
热点新闻
论坛讨论
所有讨论
公司
关于
职位招聘
数据源
历史
管理团队
博客
技术博客
新闻中心
网络讲座
Advertise With Us
常见问题
联系我们
实时地面地图仅供部分FlightAware付费订阅专享。
Surface map is loading
实时地面地图仅供部分FlightAware付费订阅专享。
实时地面地图仅供部分FlightAware付费订阅专享。
此对话框将在60秒后关闭,或者您也可以点击右上角的退出图标,马上返回飞行地图。
感谢您尝试我们全新的实时地面地图功能。我们希望您能花几分钟时间提出您的反馈意见。
意见反馈
Aircraft Details
x登录登录忘记密码了?还没有帐户吗? 现在就注册(免费),设置诸多自定义功能、航班提醒等等!
加入FlightAware
FlightAware为航空业的各个领域提供准确的实时、历史和预测性飞行洞察。
产品与服务
AeroAPI
FlightAware Firehose
FlightAware Foresight
快速报告
定制报告
FlightAware Aviator
高级订阅
FlightAware Global
FlightAware FBO Toolbox
FlightAware TV
GlobalBeacon
公司
关于
职位招聘
历史
管理团队
Advertise With Us
新闻中心
博客
网络讲座
GSA Contract # 47QTCA21D003F
社区
照片
新闻
论坛讨论
托管ADS-B站点
支持
联系我们
常见问题
Products & Services
AeroAPI
FlightAware Firehose
FlightAware Foresight
快速报告
定制报告
FlightAware Aviator
高级订阅
FlightAware Global
FlightAware FBO Toolbox
FlightAware TV
GlobalBeacon
Company
关于
职位招聘
历史
管理团队
Advertise With Us
新闻中心
博客
网络讲座
GSA Contract # 47QTCA21D003F
Community
照片
新闻
论坛讨论
托管ADS-B站点
Support
联系我们
常见问题
English (USA)
العربية
Čeština
Deutsch
English (Australia)
English (Canada)
English (UK)
English (USA)
Español (España)
Español
Suomi
Français (Canada)
Français (France)
עִבְרִית
हिन्दी
Hrvatski
Italiano
Italiano
日本語
한국어
Polski
Português (Brasil)
Português (Portugal)
Русский
Türkçe
中文(简体)
中文(香港)
中文(台灣)
2024 FlightAware
Terms of Use
Privacy
Cookie Settings
您的浏览器不支持. 升级您的浏览器
您知道FlightAware航班跟踪是由广告支持吗?
通过允许展示来自FlightAware.com的广告,您可以帮助我们使FlightAware保持免费。我们努力使我们的广告保持相关性,同时不显突兀,以创造一流的体验。在FlightAware上将广告加入白名单快捷而简单,或者请您考虑选择我们的高级帐户.
退出
CA1819:属性不应返回数组(代码分析) - .NET | Microsoft Learn
CA1819:属性不应返回数组(代码分析) - .NET | Microsoft Learn
跳转至主内容
此浏览器不再受支持。
请升级到 Microsoft Edge 以使用最新的功能、安全更新和技术支持。
下载 Microsoft Edge
有关 Internet Explorer 和 Microsoft Edge 的详细信息
目录
退出焦点模式
语言
使用英语阅读
保存
目录
使用英语阅读
保存
打印
电子邮件
目录
CA1819:属性不应返回数组
项目
09/07/2023
5 个参与者
反馈
本文内容
属性
值
规则 ID
CA1819
标题
属性不应返回数组
类别
“性能”
修复是中断修复还是非中断修复
重大
在 .NET 8 中默认启用
否
原因
属性返回数组。
默认情况下,此规则仅查看外部可见的属性和类型,但这是可配置的。
规则说明
即使属性是只读的,该属性返回的数组也不受写入保护。 若要使数组不会被更改,属性必须返回数组的副本。 通常,用户不能理解调用这种属性的负面性能影响。 具体来说,他们可能将索引属性作为属性使用。
如何解决冲突
要解决此规则的冲突,请将属性设置为方法或更改属性以返回集合。
何时禁止显示警告
可禁止显示从 Attribute 类派生的特性中由属性引发的警告。 特性可以包含返回数组的属性,但不能包含返回集合的属性。
如果属性是数据传输对象 (DTO) 类的一部分,则可以禁止显示警告.
否则,请勿禁止显示此规则发出的警告。
抑制警告
如果只想抑制单个冲突,请将预处理器指令添加到源文件以禁用该规则,然后重新启用该规则。
#pragma warning disable CA1819
// The code that's violating the rule is on this line.
#pragma warning restore CA1819
若要对文件、文件夹或项目禁用该规则,请在配置文件中将其严重性设置为 none。
[*.{cs,vb}]
dotnet_diagnostic.CA1819.severity = none
有关详细信息,请参阅如何禁止显示代码分析警告。
配置代码以进行分析
使用下面的选项来配置代码库的哪些部分要运行此规则。
包含特定的 API 图面
可以仅为此规则、为适用的所有规则或为适用的此类别(性能)中的所有规则配置此选项。 有关详细信息,请参阅代码质量规则配置选项。
包含特定的 API 图面
你可以根据代码库的可访问性,配置要针对其运行此规则的部分。 例如,若要指定规则应仅针对非公共 API 图面运行,请将以下键值对添加到项目中的 .editorconfig 文件:
dotnet_code_quality.CAXXXX.api_surface = private, internal
示例冲突
下面的示例显示了与此规则发生冲突的属性:
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] Pages
{
get { return _Pages; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = pages
End Sub
Public ReadOnly Property Pages() As String()
End Class
若要解决此规则的冲突,请将属性设置为方法或更改属性以返回集合而不是数组。
将属性更改为方法
以下示例通过将属性更改为方法来解决冲突:
Public Class Book
Private _Pages As String()
Public Sub New(ByVal pages As String())
_Pages = pages
End Sub
Public Function GetPages() As String()
' Need to return a clone of the array so that consumers
' of this library cannot change its contents
Return DirectCast(_Pages.Clone(), String())
End Function
End Class
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] GetPages()
{
// Need to return a clone of the array so that consumers
// of this library cannot change its contents
return (string[])_Pages.Clone();
}
}
更改属性以返回集合
以下示例通过更改属性以返回 System.Collections.ObjectModel.ReadOnlyCollection
public class Book
{
private ReadOnlyCollection
public Book(string[] pages)
{
_Pages = new ReadOnlyCollection
}
public ReadOnlyCollection
{
get { return _Pages; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = New ReadOnlyCollection(Of String)(pages)
End Sub
Public ReadOnly Property Pages() As ReadOnlyCollection(Of String)
End Class
允许用户修改属性
你可能希望允许类的使用者修改属性。 以下示例显示与此规则冲突的读/写属性:
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] Pages
{
get { return _Pages; }
set { _Pages = value; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = pages
End Sub
Public Property Pages() As String()
End Class
以下示例通过更改属性以返回 System.Collections.ObjectModel.Collection
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = New Collection(Of String)(pages)
End Sub
Public ReadOnly Property Pages() As Collection(Of String)
End Class
public class Book
{
private Collection
public Book(string[] pages)
{
_Pages = new Collection
}
public Collection
{
get { return _Pages; }
}
}
相关规则
CA1024:在适用处使用属性
在 GitHub 上与我们协作
可以在 GitHub 上找到此内容的源,还可以在其中创建和查看问题和拉取请求。 有关详细信息,请参阅参与者指南。
.NET
提出文档问题
提供产品反馈
反馈
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.
提交和查看相关反馈
此产品
此页面
查看所有页面反馈
其他资源
加州消费者隐私法案 (CCPA) 禁用图标
你的隐私选择
主题
亮
暗
高对比度
早期版本
博客
参与
隐私
使用条款
商标
© Microsoft 2024
其他资源
本文内容
加州消费者隐私法案 (CCPA) 禁用图标
你的隐私选择
主题
亮
暗
高对比度
早期版本
博客
参与
隐私
使用条款
商标
© Microsoft 2024
CA1819 (CCA1819) Air China Flight Tracking and History - FlightAware
CA1819 (CCA1819) Air China Flight Tracking and History - FlightAware
Products
Data Products
AeroAPI
Flight data API with on-demand flight status and flight tracking data.
FlightAware Firehose
Streaming flight data feed for enterprise integrations with real-time, historical and predictive flight data.
FlightAware Foresight
Predictive technology to strengthen customer trust in your operations
Rapid Reports
Quickly purchase historical reports delivered via email.
Custom Reports
Consultative detailed and customized flight tracking data reports.
Integrated Mapping Solutions
Incorporate FlightAware maps in your web and mobile applications
Applications
FlightAware Aviator
The ultimate flight tracking suite for small aircraft/general aviation (GA) owners and operators.
Premium Subscriptions
A personalized flight-following experience with unlimited alerts and more.
FlightAware Global
The industry standard flight tracking platform for business aviation (BA) owners and operators.
FlightAware FBO Toolbox
Comprehensive flight tracking to enhance your FBO operations and increase sales.
FlightAware TV
Full-screen FlightAware TV maps for operators or FBOs.
GlobalBeacon
GADSS-compliant global tracking and alerting for airlines and aircraft operators.
Industries
Airlines
Airports
Air Traffic Control
Owners and Operators
Government
ADS-B
Statistics
SkyAware Anywhere
Coverage Map
ADS-B Store
Build a PiAware ADS-B Receiver
FlightFeeder
FAQs
Flight Tracking
Delays and cancellations
Cancellations
Airport Delays
MiseryMap
Search flights
Flight Finder
Browse by Operator
Browse by Airport
Browse by Aircraft Type
Other
Random Airport
Random Flight
IFR Route Analyzer
Community
Photos
Popular Photos
Newest Photos
Highest Ranked
Staff Picks
Recent Comments
Community Tagging
Upload Your Photos
Squawks
Current Squawks
New Squawks
Popular Squawks
Discussions
All Discussions
Company
About
Careers
Data Sources
History
Executive Team
Blog
Engineering Blog
Newsroom
Webinars
Advertise With Us
FAQs
Contact Us
Create a FlightAware Account
or log in to an existing account
Get the FlightAware App for the best flight tracking experience on your device.
Join FlightAware Login04:39AM EST
العربية
Čeština
Deutsch
English (Australia)
English (Canada)
English (UK)
English (USA)
Español (España)
Español
Suomi
Français (Canada)
Français (France)
עִבְרִית
हिन्दी
Hrvatski
Italiano
日本語
한국어
Polski
Português (Brasil)
Português (Portugal)
Русский
Türkçe
中文(简体)
中文(香港)
中文(台灣)
AllAllRouteAirline flightPrivate flight (tail #)Airport Sign Up
Products
Data Products
AeroAPI
Flight data API with on-demand flight status and flight tracking data.
FlightAware Firehose
Streaming flight data feed for enterprise integrations with real-time, historical and predictive flight data.
FlightAware Foresight
Predictive technology to strengthen customer trust in your operations
Rapid Reports
Quickly purchase historical reports delivered via email.
Custom Reports
Consultative detailed and customized flight tracking data reports.
Integrated Mapping Solutions
Incorporate FlightAware maps in your web and mobile applications
Applications
FlightAware Aviator
The ultimate flight tracking suite for small aircraft/general aviation (GA) owners and operators.
Premium Subscriptions
A personalized flight-following experience with unlimited alerts and more.
FlightAware Global
The industry standard flight tracking platform for business aviation (BA) owners and operators.
FlightAware FBO Toolbox
Comprehensive flight tracking to enhance your FBO operations and increase sales.
FlightAware TV
Full-screen FlightAware TV maps for operators or FBOs.
GlobalBeacon
GADSS-compliant global tracking and alerting for airlines and aircraft operators.
Industries
Airlines
Airports
Air Traffic Control
Owners and Operators
Government
ADS-B
Statistics
SkyAware Anywhere
Coverage Map
ADS-B Store
Build a PiAware ADS-B Receiver
FlightFeeder
FAQs
Flight Tracking
Delays and cancellations
Cancellations
Airport Delays
MiseryMap
Search flights
Flight Finder
Browse by Operator
Browse by Airport
Browse by Aircraft Type
Other
Random Airport
Random Flight
IFR Route Analyzer
Download the FlightAware app today.
Community
Photos
Popular Photos
Newest Photos
Highest Ranked
Staff Picks
Recent Comments
Community Tagging
Upload Your Photos
Squawks
Current Squawks
New Squawks
Popular Squawks
Discussions
All Discussions
Company
About
Careers
Data Sources
History
Executive Team
Blog
Engineering Blog
Newsroom
Webinars
Advertise With Us
FAQs
Contact Us
Live Surface MapAvailable exclusively for select FlightAware paid subscriptions.
Surface map is loading
Live Surface MapAvailable exclusively for select FlightAware paid subscriptions.
Live Surface MapAvailable exclusively for select FlightAware paid subscriptions.
This dialogue will close in 60 seconds or you can click the exit icon in the top right corner to go back to the flight map immediately.
We appreciate you trying our new Live Surface Map feature. If you have a couple of minutes, we'd like to collect your feedback on it.
Give Feedback
Aircraft Details
xLoginLoginForgot password?Don't have an account? Register now (free) for customized features, flight alerts, and more!
Join FlightAware
FlightAware provides accurate real-time, historical and predictive flight insights to all segments of the
aviation industry.
Products & Services
AeroAPI
FlightAware Firehose
FlightAware Foresight
Rapid Reports
Custom Reports
FlightAware Aviator
Premium Subscriptions
FlightAware Global
FlightAware FBO Toolbox
FlightAware TV℠
GlobalBeacon
Company
About
Careers
History
Executive Team
Advertise With Us
Newsroom
Blog
Webinars
GSA Contract # 47QTCA21D003F
Community
Photos
Squawks
Discussions
Host an ADS-B Site
Support
Contact Us
FAQs
Products & Services
AeroAPI
FlightAware Firehose
FlightAware Foresight
Rapid Reports
Custom Reports
FlightAware Aviator
Premium Subscriptions
FlightAware Global
FlightAware FBO Toolbox
FlightAware TV℠
GlobalBeacon
Company
About
Careers
History
Executive Team
Advertise With Us
Newsroom
Blog
Webinars
GSA Contract # 47QTCA21D003F
Community
Photos
Squawks
Discussions
Host an ADS-B Site
Support
Contact Us
FAQs
English (USA)
العربية
Čeština
Deutsch
English (Australia)
English (Canada)
English (UK)
English (USA)
Español (España)
Español
Suomi
Français (Canada)
Français (France)
עִבְרִית
हिन्दी
Hrvatski
Italiano
Italiano
日本語
한국어
Polski
Português (Brasil)
Português (Portugal)
Русский
Türkçe
中文(简体)
中文(香港)
中文(台灣)
2024 FlightAware
Terms of Use
Privacy
Cookie Settings
Your browser is unsupported. upgrade your browser
Did you know that FlightAware flight tracking is supported by advertising?
You can help us keep FlightAware free by allowing ads from FlightAware.com. We work hard to keep our advertising relevant and unobtrusive to create a great experience. It's quick and easy to whitelist ads on FlightAware or please consider our premium accounts.
Dismiss
CA1819: Properties should not return arrays (code analysis) - .NET | Microsoft Learn
CA1819: Properties should not return arrays (code analysis) - .NET | Microsoft Learn
Skip to main content
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
Table of contents
Exit focus mode
Language
Read in English
Save
Table of contents
Read in English
Save
Edit
Table of contents
CA1819: Properties should not return arrays
Article
09/05/2023
5 contributors
Feedback
In this article
Property
Value
Rule ID
CA1819
Title
Properties should not return arrays
Category
Performance
Fix is breaking or non-breaking
Breaking
Enabled by default in .NET 8
No
Cause
A property returns an array.
By default, this rule only looks at externally visible properties and types, but this is configurable.
Rule description
Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the property must return a copy of the array. Typically, users won't understand the adverse performance implications of calling such a property. Specifically, they might use the property as an indexed property.
How to fix violations
To fix a violation of this rule, either make the property a method or change the property to return a collection.
When to suppress warnings
You can suppress a warning that's raised for a property of an attribute that's derived from the Attribute class. Attributes can contain properties that return arrays, but can't contain properties that return collections.
You can suppress the warning if the property is part of a Data Transfer Object (DTO) class.
Otherwise, do not suppress a warning from this rule.
Suppress a warning
If you just want to suppress a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable CA1819
// The code that's violating the rule is on this line.
#pragma warning restore CA1819
To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.CA1819.severity = none
For more information, see How to suppress code analysis warnings.
Configure code to analyze
Use the following option to configure which parts of your codebase to run this rule on.
Include specific API surfaces
You can configure this option for just this rule, for all rules it applies to, or for all rules in this category (Performance) that it applies to. For more information, see Code quality rule configuration options.
Include specific API surfaces
You can configure which parts of your codebase to run this rule on, based on their accessibility. For example, to specify that the rule should run only against the non-public API surface, add the following key-value pair to an .editorconfig file in your project:
dotnet_code_quality.CAXXXX.api_surface = private, internal
Example violation
The following example shows a property that violates this rule:
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] Pages
{
get { return _Pages; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = pages
End Sub
Public ReadOnly Property Pages() As String()
End Class
To fix a violation of this rule, either make the property a method or change the property to return a collection instead of an array.
Change the property to a method
The following example fixes the violation by changing the property to a method:
Public Class Book
Private _Pages As String()
Public Sub New(ByVal pages As String())
_Pages = pages
End Sub
Public Function GetPages() As String()
' Need to return a clone of the array so that consumers
' of this library cannot change its contents
Return DirectCast(_Pages.Clone(), String())
End Function
End Class
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] GetPages()
{
// Need to return a clone of the array so that consumers
// of this library cannot change its contents
return (string[])_Pages.Clone();
}
}
Change the property to return a collection
The following example fixes the violation by changing the property to return a System.Collections.ObjectModel.ReadOnlyCollection
public class Book
{
private ReadOnlyCollection
public Book(string[] pages)
{
_Pages = new ReadOnlyCollection
}
public ReadOnlyCollection
{
get { return _Pages; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = New ReadOnlyCollection(Of String)(pages)
End Sub
Public ReadOnly Property Pages() As ReadOnlyCollection(Of String)
End Class
Allow users to modify a property
You might want to allow the consumer of the class to modify a property. The following example shows a read/write property that violates this rule:
public class Book
{
private string[] _Pages;
public Book(string[] pages)
{
_Pages = pages;
}
public string[] Pages
{
get { return _Pages; }
set { _Pages = value; }
}
}
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = pages
End Sub
Public Property Pages() As String()
End Class
The following example fixes the violation by changing the property to return a System.Collections.ObjectModel.Collection
Public Class Book
Public Sub New(ByVal pages As String())
Me.Pages = New Collection(Of String)(pages)
End Sub
Public ReadOnly Property Pages() As Collection(Of String)
End Class
public class Book
{
private Collection
public Book(string[] pages)
{
_Pages = new Collection
}
public Collection
{
get { return _Pages; }
}
}
Related rules
CA1024: Use properties where appropriate
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET
Open a documentation issue
Provide product feedback
Feedback
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback.
Submit and view feedback for
This product
This page
View all page feedback
Additional resources
California Consumer Privacy Act (CCPA) Opt-Out Icon
Your Privacy Choices
Theme
Light
Dark
High contrast
Previous Versions
Blog
Contribute
Privacy
Terms of Use
Trademarks
© Microsoft 2024
Additional resources
In this article
California Consumer Privacy Act (CCPA) Opt-Out Icon
Your Privacy Choices
Theme
Light
Dark
High contrast
Previous Versions
Blog
Contribute
Privacy
Terms of Use
Trademarks
© Microsoft 2024
CA1819: 属性不应返回数组 - 正确的替代方案是什么? c# .net fxcop - Dev59
19: 属性不应返回数组 - 正确的替代方案是什么? c# .net fxcop - Dev59标签列表CA1819: 属性不应返回数组 - 正确的替代方案是什么?c#.netfxcop1616我之前也遇到过这个FxCop规则,对于如何解决违例并不满意(thread1,thread2)。现在我又有了一个需要修复CA1819问题的案例。具体来说,我有一个算法库,对曲线(x,y)进行一些分析计算,其中公共的“输入对象”是这样的:public class InputObject
{
public double[] X { get; set; }
public double[] Y { get; set; }
// + lots of other things well
}
在该库中,这个对象的X和Y属性通常使用索引,在数百个位置中使用。算法从未更改输入对象,但实际上即使更改也不应该影响结果。此外,.Length经常被调用。这是一个数学库,其中double[]是标准数据类型。无论如何,修复CA1819需要相当多的工作。
我考虑使用List
用什么选项替换这些double[]属性最好呢?- Efrain2@skk,这就是问题链接到的“thread1”... - AakashM(请注意,您必须格式化角括号以使它们出现在文本中) - AakashM5个回答1313如果只是读取给外部使用且消费者不希望通过索引访问它,则最好具有公共的只读属性,其类型为IEnumerable<>,并带有添加和删除的方法访问器,这样您就不必将您的数组暴露给别人随意更改。如果需要访问索引,则将其公开为只读属性,其类型为IList<>,并可能返回一个只读实例,带有添加和删除等方法。这样,您保持了内部列表的封装性,并允许用户以只读方式访问它。- Mohamed Abed31感谢您的输入,这正是我所做的...特别是因为还有另一个FxCop规则(CA2227,http://msdn.microsoft.com/de-de/library/ms182327.aspx)强制我这样做。 ;) - Efrain1个人而言,如果我想向调用者暗示属性可能是惰性评估的,我只会使用IEnumerable
这完全取决于你要做什么,如果你正在编写一个需要安全性和非常干净的代码的复杂系统,你应该返回该数组的只读版本。
也就是说,像devdigital建议的那样将数组转换为IEnumerable,或者使用Mohamed Abed的好主意ImmutableArray,我更喜欢后者。
如果你正在编写需要高性能的软件...在C#中,没有比数组更好的性能了。
对于迭代和读取,数组可以更快。
如果性能真的很重要,我建议你忽略那个警告。
即使不太干净,返回只读数组仍然合法。
for (int i = 0; i < array.Length; ++i) { k = array[i] + 1; }
对于C#中的大型数组来说,这非常快:它避免了数组边界检查。
它将表现得非常像编译后的C代码。
我一直希望在C#中有一个“只读数组”类型 :) 但是我们没有希望看到它。
- Salvatore Previti3我一直希望C#中有一个“只读数组”类型 - ReadOnlyCollection
public interface IArray
{
int Length { get; }
T this[int index] { get; }
}
internal sealed class ImmutableArray
where T : struct
{
private readonly T[] _wrappedArray;
internal ImmutableArray(IEnumerable
{
this._wrappedArray = data.ToArray();
}
public int Length
{
get { return this._wrappedArray.Length; }
}
public T this[int index]
{
get { return this._wrappedArray[index]; }
}
}
public class InputObject
{
private readonly IArray
private readonly IArray
public InputObject(double[] x, double[] y)
{
this._x = new ImmutableArray
this._y = new ImmutableArray
}
public IArray
{
get { return this._x; }
}
public IArray
{
get { return this._y; }
}
//...
}
如果T是可变的,那么您“不可变”数组内容中的元素仍然是可变的,但至少对于双精度类型,您是安全的。
- Nicole Calinoiu5使用已经存在于框架中的类似IList
public class InputObject
{
public IEnumerable
public IEnumerable
// + lots of other things well
}
- Jhonny Ramirez Zeballos回答链接网页内容由stack overflow 提供, 点击上面的可以查看英文原文, 原文链接相关问题28 属性不应返回数组5 AppDomain.AppendPrivatePath的替代方案是什么?6 Microsoft.Azure.WebJobs.Hosting.JobHostConfiguration的替代方案是什么?90 静态方法继承的正确替代方案是什么?12 WPF的替代方案是什么?3 CLS兼容的ulong属性的替代方案是什么?5 属性的替代方案是什么?5 CA1819: 属性不应返回数组。这个规则适用于其他对象吗?4 Request.IsLocal的替代方案是什么?3 System.Collections.ArrayList的替代方案是什么?© 2023 根据CC BY-SA 4.0 许可证授权京ICP备19056307
【CA1819】航班查询_中国国际航空CA1819_北京到南京飞机CA1819_途牛机票
【CA1819】航班查询_中国国际航空CA1819_北京到南京飞机CA1819_途牛机票
登录|注册
网站无障碍
关怀版
途牛首页
途牛商旅
旅游百货
企业旅游
会员俱乐部
我的订单
全部订单
我的机票
我的火车票
积分商城
网站地图
去旅游
跟团游
自由行
酒+景
公司旅游
当地活动
首付出发
牛人专线
亲子游
蜜月游
海岛游
老于推荐
酒店
门票
邮轮
签证
机票
旅拍
寻优惠
特卖
订酒店 返现金
积分商城
银行特惠游
看攻略
攻略
途牛风向标
游记
达人玩法
查服务
帮助中心
会员俱乐部
阳光保障
火车时刻表
航班查询
酒店所有产品跟团游自由行邮轮门票自驾游当地游当地活动签证酒店旅拍定制包团森林三亚北京
高级搜索
24h客户服务电话
4007-999-999
首页
跟团游
出境跟团
境内跟团
周边跟团
私家团
自由行
出境自由行
境内自由行
签证
牛人专线
自驾游
机票
出境·中国港澳台机票
境内机票
火车票
酒店
出境·中国港澳台酒店
境内酒店
门票
主题游
亲子游
蜜月游
爸妈游
红色旅游
邮轮游
日韩航线
东南亚航线
三峡航线
出游服务
旅游百货
签证
定制游
公司定制
家庭定制
会议&奖励旅游
朋派定制游
金融
理财
途牛宝
保险
礼品卡
攻略
游记
达人玩法
风向标
旅游达人
首页>
机票>
航班查询>
北京航班>
北京到南京航班>
CA1819
航班时刻查询
航线查询
出发城市
中文/拼音
到达城市
中文/拼音
查询
航班号查询
请输入航班号
查询
CA1819
航班时刻表
航空公司/航班号
起飞时间
到达时间
本周参考班期
出发时间
中国国际航空CA1819 中型机20:20首都国际机场22:25禄口国际机场1234567 查询
友情提示:航班时刻表信息仅供参考,如有出入请以实际航班信息为准
北京首都国际机场电话:咨询电话:010-96158;停车场:010-64540814;失物招领:010-64598333;投诉电话:010-96158;临时身份证:010-64597459。地址:北京市顺义区机场西路 简介:北京首都国际机场位于北京市东北侧六环内,距离市区中心的车程大约30公里,是全中国规模一流、运输繁忙的大型国际航空港。作为中国第 一国门,这里也是全世界设施及服务极先进的机场之一,拥有十分高效、细致的航空服务。
机场目前共有三座航站楼,航站楼间有免费的摆渡车可以方便中转。而各航站楼内部,也有便捷的设施帮助旅客出行,Wifi覆盖、咨询问讯处、休息区、购物区、商务中心、儿童游乐区、行李寄存与搬运、特殊旅客便利设施等一应俱全,可以满足一般旅客所有的出行需求。
同时,机场开通了前往市区中心的地铁线和十几条大巴路线,还有通向天津、秦皇岛、唐山等津冀主要城市的直通班车,交通非常方便,旅客可以在此感受便捷、舒适的出行体验。南京禄口国际机场电话:咨询电话:025-96066;投诉电话:025-52480315;临时身份证:025-69820351;商务中心:025-52480278;停车场:025-52480167。地址:江苏省南京市江宁区禄口镇空港路 简介:南京禄口国际机场,位于南京市江宁区禄口镇,是江苏省和南京市的门户,是国家主要干线机场、华东地区的主要货运机场,与上海虹桥机场、浦东机场互为备降机场,位列全国千万级大型机场行列,是国家大型枢纽机场、中国航空货物中心和快件集散中心,国家区域交通枢纽。距市区约36公里,拥有通往54个国内主要城市、20个国际和3个地区城市的130余条航线。目前承载着中国国际航空、东方航空、南方航空、新加坡航空、德国汉莎航空、韩国韩亚航空等多家航空公司航班。
超值特价机票
航司专区
东方航空
海南航空
南京西安¥4703.1折 广州南京¥4002.3折 北京三亚¥5001.1折
邻近航班SC5125CA1817ZH1817KN6075MU2862MU2812CA1847ZH1847G56898MF3416KN6065CA1561ZH1561MU2832SC5057CA1503ZH1503MU2842KN6069ZH4865CA8601SC5295CA1819ZH1819SC5127
机票推荐牡丹江到烟台机票郑州到天津机票景德镇到广州机票成都到敦煌市机票西安到三亚机票武汉到海口机票徐州到丽江机票大连到哈尔滨机票石家庄到三亚机票南通到广州机票合肥到黄山机票长沙到成都机票阜阳到厦门机票潍坊到北京机票银川到南京机票南京到遵义机票牡丹江到沈阳机票大连到兰州机票西安到张掖机票阜阳到天津机票
去旅游
跟团游
牛人专线
酒店
自由行
亲子游
门票
酒+景
蜜月游
邮轮
公司旅游
海岛游
签证
当地活动
老于推荐
机票
首付出发
旅拍
寻优惠
特卖
订酒店 返现金
积分商城
银行特惠游
看攻略
攻略
途牛风向标
游记
达人玩法
查服务
帮助中心
会员俱乐部
阳光保障
火车时刻表
航班查询
途牛APP
扫描下载途牛APP
客户服务电话
4007-999-999
途牛客服中心设立在江苏南京及江苏宿迁,来电显示号码请查看: 途牛会员中心外呼电话号码汇总
北京途牛国际旅行社有限公司,旅行社业务经营许可证编号:L-BJ-CJ00144 上海途牛国际旅行社有限公司,旅行社业务经营许可证编号:L-SH-CJ00107
关于我们
Investor Relations
联系我们
投诉建议与举报
广告服务
旅游券
途牛招聘
隐私保护
免责声明
旅游度假资质
主题旅游
平台服务协议
平台交易规则
网站地图
攻略地图
UEIP
帮助中心
网信办辟谣专栏
Copyright © 2006-2024 南京途牛科技有限公司
Tuniu.com |
营业执照 |
ICP证:苏B2-20130006 |
苏ICP备12009060号-4 |
苏网食备A32000000032 |
上海旅游网
全国旅游投诉热线12345
Air China flight CA1819 - Flightradar24
Air China flight CA1819 - Flightradar24Map Misc Labels appear when there are less than 400 aircraft on map. The second to fourth row will appear only when the map is zoomed in.Map styleTerrain TerrainRoadmapGreyscaleRadar (blue)Radar (dark)Aubergine (dark)SatelliteHybridBlack/WhiteBrightnessDay/night line Personalized ads Show times in local airport time rather than UTC.UnitsLocal airport time 12-hour clockTemperature°C Celsius °CFarenheit °F Aircraft speedKnots KnotsKm/hMphVertical speedFpm FpmM/s Wind speedKnots KnotsKm/hMphM/s AltitudeFeet FeetMetersDistanceKm KmMilesNm Reset all settings
Flight Tracker Map
>
Aviation Data
>
Flights
>
CA1819
Flight history for Air China flight CA1819 GREAT CIRCLE DISTANCE AVERAGE FLIGHT TIME ACTUAL FLIGHT TIME AVERAGE ARRIVAL DELAY FROM TO TIME UTC CALIBRATED ALTITUDE GPS ALTITUDE GROUND SPEED TRUE AIRSPEED VERTICAL SPEED INDICATED AIRSPEED TRACK SQUAWK AIRCRAFT REGISTRATION SERIAL NUMBER (MSN)
FLIGHTS HISTORY DATEFROMTOAIRCRAFTFLIGHT TIMESTDATDSTASTATUS — 15 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 15 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 14 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 14 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 13 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 13 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 12 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 12 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 11 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 11 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 10 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 10 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 09 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 09 Mar 2024 Beijing (PEK) Nanjing (NKG) 32Q — 12:30 — 14:10 Scheduled Play — 08 Mar 2024 - Scheduled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 08 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Scheduled Play — 07 Mar 2024 - Canceled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 07 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Canceled Play B-1417 06 Mar 2024 1:30 Landed 14:05 STD 12:30 ATD 12:35 STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 06 Mar 2024 Beijing (PEK) Nanjing (NKG) B738 (B-1417) 1:30 12:30 12:35 14:10 Landed 14:05 KML CSV Play B-5343 05 Mar 2024 1:29 Landed 14:24 STD 12:30 ATD 12:56 STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 05 Mar 2024 Beijing (PEK) Nanjing (NKG) B738 (B-5343) 1:29 12:30 12:56 14:10 Landed 14:24 KML CSV Play — 04 Mar 2024 - Canceled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 04 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Canceled Play B-1416 03 Mar 2024 1:28 Landed 14:07 STD 12:30 ATD 12:39 STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 03 Mar 2024 Beijing (PEK) Nanjing (NKG) B738 (B-1416) 1:28 12:30 12:39 14:10 Landed 14:07 KML CSV Play — 02 Mar 2024 - Canceled STD 12:30 ATD — STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 02 Mar 2024 Beijing (PEK) Nanjing (NKG) 738 — 12:30 — 14:10 Canceled Play B-6792 01 Mar 2024 1:26 Landed 14:33 STD 12:30 ATD 13:07 STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 01 Mar 2024 Beijing (PEK) Nanjing (NKG) A321 (B-6792) 1:26 12:30 13:07 14:10 Landed 14:33 KML CSV Play B-5803 29 Feb 2024 1:29 Landed 14:23 STD 12:30 ATD 12:54 STA 14:10 FROM Beijing (PEK) TO Nanjing (NKG) 29 Feb 2024 Beijing (PEK) Nanjing (NKG) B737 (B-5803) 1:29 12:30 12:54 14:10 Landed 14:23 KML CSV Play More than 7 days of CA1819 history is available with an upgrade to a Silver (90 days), Gold (1 year), or Business (3 years) subscription. 7-day FREE trial | Learn more © 2024 Flightradar24 ABContact usFAQCareersPrivacyTerms
7-day FREE trial | Learn moreCreate free Flightradar24 account Learn more about subscriptions You have used up all of your 3D view sessions.Don't worry, you can get unlimited sessions with a Flightradar24 subscription.7-day free trial | Learn moreOr you can watch a short video to get more free sessions!Watch now
c# - CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why? - Software Engineering Stack Exchange
c# - CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why? - Software Engineering Stack Exchange
Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Loading…
Tour
Start here for a quick overview of the site
Help Center
Detailed answers to any questions you might have
Meta
Discuss the workings and policies of this site
About Us
Learn more about Stack Overflow the company, and our products
current community
Software Engineering
help
chat
Software Engineering Meta
your communities
Sign up or log in to customize your list.
more stack exchange communities
company blog
Log in
Sign up
Home
Questions
Tags
Users
Companies
Unanswered
Teams
Stack Overflow for Teams
– Start collaborating and sharing organizational knowledge.
Create a free Team
Why Teams?
Teams
Create free Team
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why?
Ask Question
Asked
10 years, 6 months ago
Modified
7 years, 2 months ago
Viewed
6k times
8
I have a question about CA1819 msdn performance warning.
The rule is: Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the property must return a copy of the array. Typically, users will not understand the adverse performance implications of calling such a property. Specifically, they might use the property as an indexed property.
I understand the rule.
I want to know if this happens only with arrays? If yes, why?
c#array
Share
Improve this question
Follow
edited Dec 10, 2016 at 23:46
Thomas Owens♦
82.4k1818 gold badges202202 silver badges293293 bronze badges
asked Sep 9, 2013 at 15:00
KrissKriss
8111 silver badge44 bronze badges
Add a comment
|
2 Answers
2
Sorted by:
Reset to default
Highest score (default)
Date modified (newest first)
Date created (oldest first)
7
Arrays are reference types. That is when a property returns an array object it's returning a pointer/reference to it's internal array. The caller of the property can now modify that internal array (as they have a pointer to it), this is generally unwanted. To stop this you can return a copy of the internal array but now your doing a memory allocation and copy every time the property is used, and given that properties are meant to be light-weight that's not good.
This happens with any reference type that is mutable. If you have a private reference to a mutable reference type (Like a Stream, List or Dictionary) and you return that reference in a property than the caller can modify your data. If you have a value type (structs in C#) than they are always copied when they're returned from the property so the caller can't then modify your internal version of the data.
Share
Improve this answer
Follow
answered Sep 9, 2013 at 15:07
IbasaIbasa
17133 bronze badges
9
2
I would only note that making a copy of the array only protects the original array from tampering, not the new one. See also stackoverflow.com/a/210444
– Robert Harvey
Sep 9, 2013 at 15:16
link. @ibasa. this article says that if collection are used (lists) then the problem can be fixed. And list is a reference type. Lets take an example 'code' private IDbCommand idbCommand;public IDbCommand Command { get { return idbCommand; } } when i try to change idbCommand from an outer class it does not allow me even though idCommand is a reference type. Thanks
– Kriss
Sep 9, 2013 at 15:19
You can just return IEnumerable
– brian
Sep 9, 2013 at 15:30
3
See also blogs.msdn.com/b/dotnet/archive/2013/06/24/…
– Robert Harvey
Sep 9, 2013 at 15:32
1
@Kriss it isn't just arrays, any reference type can be modified when returned from a property. Strings are immutable by the language definition, no other type is. You can certainly modify an IDbCommand if you return it from a property. The warning is about the performance implications of returning a copy of an array through a property then some unsuspecting dev using it in a foreach thus causing a copy of the entire array on every step through the iteration.
– stonemetal
Sep 10, 2013 at 17:21
|
Show 4 more comments
4
Well, first off, .net has introduced IReadOnlyList and IReadOnlyDictionary which address this problem for generics(which is preferable to a base array), previously you would have to had created your own interface in order to see the same performance with the same restriction.
The basic problem, and no, it's not limited to arrays, is that you want to provide a method of accessing a bunch of items without requiring that they be iterated, but you don't want the consumer of your API to be adding or deleting items -- but previously all of the built in interfaces that allow what you want, also allowed what you don't want.
The suggested solution is both inefficient (creating a clone is slow) and misleading -- the consumer gets an array that he thinks he can modify and have that effect the object that returned it. Ie he thinks if he adds an element and then calls the property again, he will get an array with p+1 items. He also expects that o.ItemArray.Equals(o.ItemArray). Neither of these expectations will be true.
As a practical problem, this is no longer a problem if you can use the right version of the framework and something other than an array.
As for the performance problem...
if(o.ItemArray.Equals(o.ItemArray) || o.ItemArray.Equals(o2.ItemArray))
Creates 4 copies of a potentially large array.
Edit in response to comment:
This is not a problem specific to Arrays. List and Dictionaries are also mutable.
IList
lst.Add("hello");
lst[0]="bye";
Console.WriteLine(lst[0]);
And the above code sample shows the problems with mutable list as properties. Suppose that I had a class, Greetings, which had a list of words and phrases that you would use upon meeting someone. Hello, Hi, Hola, Hey dude, Whats up! Como esta and so forth. So, I have a property Words, and return the above lst. You can then immediately execute the 3rd line and change my "hello" to "bye" --for everyone that has a reference to that instance of the class.
But as I said, in 4.5, you would get around this by having your list be IReadOnlyLst and, using this...
return (IReadOnlyList
Share
Improve this answer
Follow
edited Sep 10, 2013 at 8:01
answered Sep 9, 2013 at 15:48
jmorenojmoreno
10.9k11 gold badge3131 silver badges4848 bronze badges
13
To have to make a copy of an array because arrays are mutable is one of the many defects of C# in my humble opinion. Default behavior in a programming language should be efficient, not inefficient.
– Neil
Sep 9, 2013 at 15:58
@Neil There are probably many performance-intensive C#, or C++, programs that use warning-inducing code all over the place, simply because of they're aware of the risks and know how to use them properly. Unless I've misinterpreted the warning mentioned, and it actually refuses to return the same-copy array, even with a warning.
– Katana314
Sep 9, 2013 at 16:04
@Neil Is there any specific reason why only arrays can be modified? Other objects like string,list, IDbCommand etc. are not mutable. I think there is something that makes arrays mutable and other objects immutable, and that's what i am asking, do anyone know that reason?
– Kriss
Sep 10, 2013 at 7:34
@Kriss It was a decision made when they were determining how C# would work. I'm sure there are other objects which can be modified as well. I suppose the main reason for making arrays mutable was to offer both options to the programmer. I don't have a problem with alternatives, but the "default" should be the more efficient version in my humble opinion.
– Neil
Sep 10, 2013 at 7:55
@jmoreno Yes you are right, lists are mutable too by index. But why can't we do the same thing with strings? What is the reason that string are not mutable? Can we say that only objects that can be accessed by index(array,list,etc) are mutable?
– Kriss
Sep 10, 2013 at 8:35
|
Show 8 more comments
Your Answer
Thanks for contributing an answer to Software Engineering Stack Exchange!Please be sure to answer the question. Provide details and share your research!But avoid …Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.
Draft saved
Draft discarded
Sign up or log in
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Submit
Post as a guest
Name
Required, but never shown
Post as a guest
Name
Required, but never shown
Post Your Answer
Discard
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged c#array or ask your own question.
The Overflow Blog
Chunking express: An expert breaks down how to build your RAG system
Building GenAI features in practice with Intuit Mailchimp
Featured on Meta
Our partnership with Google and commitment to socially responsible AI
Shifting the data dump schedule: A proposal
Related
12
What is the point of properties?
0
Why does the modifier access for the properties need to be public with Unity?
10
Why do arrays in Java not override equals()?
32
How does the "Fourth Dimension" work with arrays?
59
Why does C# allow properties in interfaces?
3
Separation of concerns between repository and service in DDD with complex entities
2
Why does this use of IEnumerable, List, and Arrays seem to get modified when it shouldn't be?
3
Overflow Exception Checking Problem
3
Mutually dependent Properties in WPF
Hot Network Questions
How to amend 2023 federal return after refund has been issued?
Why is builtin sorted() slower for a list containing descending numbers if each number appears twice consecutively?
Is there a general purpose scripting language that I can expect to find on (almost) all Windows installations?
How to make table combining multiple columns in R
Is it a good idea to give partial points in grading
Is there a language to write programmes by pictures?
How to crop complex (vector) graphics in Illustrator
How can I stop the flickering of the LED bulbs after having replaced the C7 incandescent 7w bulbs with LED's on an old scoreboard?
Is the spellcaster aware if their clone is destroyed?
Rocket attached to a pendulum. How is energy conserved?
Highlight dates in DateListStepPlot
Are there actually any photons in orbit in the photon sphere of a black hole?
Do automakers ECU-tune their motors to make new models and versions?
Conflict of interests of reviewing paper if I have talked to the author
Why is my clear wood finish drying orange?
Confusion with polling data by an MCU using UART
Manga where the main character is reborn in a game as a child villainess who hangs out with the two male leads in a greenhouse
The horizontal gap/kern before the comma is too large with unicode-math
Why is my Windows drive is appearing as encrypted in Linux (Ubuntu)?
Australian landmarks
What methods were used for password encryption before adoption of DES?
Interaction clarification with 'Invoke curse' and temporary hitpoints
Did SCOTUS have the authority to rule on McConnell's refusal to allow Obama to fill a SCOTUS vacancy?
One-Dimensional Pinball
more hot questions
Question feed
Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
lang-cs
Software Engineering
Tour
Help
Chat
Contact
Feedback
Company
Stack Overflow
Teams
Advertising
Collectives
Talent
About
Press
Legal
Privacy Policy
Terms of Service
Cookie Settings
Cookie Policy
Stack Exchange Network
Technology
Culture & recreation
Life & arts
Science
Professional
Business
API
Data
Blog
Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA. rev 2024.3.5.5754