相关疑难解决方法(0)

如果字符串在.NET中是不可变的,那么为什么Substring需要O(n)时间?

鉴于字符串在.NET中是不可变的,我想知道为什么它们被设计为string.Substring()需要O(substring.Length)时间,而不是O(1)

即,有什么权衡,如果有的话?

.net c# string substring time-complexity

446
推荐指数
5
解决办法
2万
查看次数

标签 统计

.net ×1

c# ×1

string ×1

substring ×1

time-complexity ×1