c# - 如何更新 List<T> 元素集合中的特定元素?

标签 c#

我有一个自定义对象列表,我想更新一个特定元素,比如从顶部开始的第 3 个元素,我该如何在 C# 中执行此操作?

最佳答案

// Updates a property or member of the item
myList[2].myProperty = something;

// Replaces the item in the list
myList[2] = someNewItem;

关于c# - 如何更新 List<T> 元素集合中的特定元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1105411/

相关文章:

c# - 如何限制 DictationGrammar 对象中的单词?

c# - 如何从asp.net core mvc html helper静态方法中的html helper上下文获取urlHelper

c# - DDD : one-to-many relationship between user aggregate root and almost all entities in other aggregates

c# - 在 .NET (C#) 中按键/值对的位置随机访问

c# - Azure BlobClient DeleteIfExistsAsync 错误 : 404 The specified blob does not exist

c# - 如何为连接到 SQL 数据库的项目创建安装文件?

c# - 如何更改组合框控件中的下拉按钮?

c# - 测试一种发送电子邮件但不发送邮件的方法

c# - 将新的 Microsoft Edge 添加到 Web 浏览器控件?

c# - 什么是锁定线程的正确方法?