修改List <T>的内容时"无法修改返回值"错误

Boa*_*rdy 3 c#

我目前正在开发一个C#项目,我需要将数据添加到自定义List数组中.然后,我需要枚举列表,查找特定记录然后修改数据.但是,我在Visual Studio中收到错误

Cannot modify the return value of System.Collections.Generic.List<EmailServer.ThreadCheck>.this[int] because it is not a variable. 
Run Code Online (Sandbox Code Playgroud)

下面是初始化List Array的代码

static List<ThreadCheck> threadKick = new List<ThreadCheck>();
Run Code Online (Sandbox Code Playgroud)

下面是我如何将数据添加到List数组

public static void addThread(ILibraryInterface library, int threadID, string threadName)
{
    if (Watchdog.library == null)
    {
        Watchdog.library = library;
    }
    long currentEpochTime = library.convertDateTimeToEpoch(DateTime.Now);
    threadKick.Add(new ThreadCheck()
    {
        threadName = threadName,
        threadID = threadID,
        epochTimeStamp = currentEpochTime
    });
    library.logging(classDetails + MethodInfo.GetCurrentMethod().Name, string.Format("Thread ID: {0} has been added to watchdog for {1}",
        threadID, threadName));
}
Run Code Online (Sandbox Code Playgroud)

下面是我试图修改列表中的数据的代码

public static void kickThread(int threadId)
{
    lock (threadKick)
    {
        for (int i = 0; i < threadKick.Count; i++)
        {
            if (threadKick[i].threadID == threadId)
            {
                threadKick[i].epochTimeStamp = library.convertDateTimeToEpoch(DateTime.Now);
                break;
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如何在不收到上述错误的情况下修改列表数组的内容?

SLa*_*aks 8

欢迎来到邪恶可变结构的奇妙世界!

更改ThreadCheckclass,一切都将正常工作.