gpt4 book ai didi

c# - 更改 C# 字符串中特定索引处字符的默认方法是什么?

转载 作者:太空狗 更新时间:2023-10-29 23:58:07 25 4
gpt4 key购买 nike

<分区>

我有一个像这样的字符串:

string s = "abc";

我想将第二个字符更改为“d”,这样它就是“adc”我认为这会起作用:

s[1] = 'd';

但是我得到一个错误:

Property or indexer 'string.this[int] 'cannot be assigned to -- it is read only

我怎样才能完成这个简单的任务(不使用相当复杂的子字符串方法?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com