You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -21,11 +21,11 @@ public sealed class StringBuilder
21
21
{
22
22
#region Fields
23
23
24
-
int_maxCapacity;
25
-
char[]_chunkChars;
26
-
int_chunkLength;
27
-
StringBuilder_chunkPrevious;
28
-
int_chunkOffset;
24
+
privatereadonlyint_maxCapacity;
25
+
privatechar[]_chunkChars;
26
+
privateint_chunkLength;
27
+
privateStringBuilder_chunkPrevious;
28
+
privateint_chunkOffset;
29
29
30
30
#endregion
31
31
@@ -35,67 +35,77 @@ public sealed class StringBuilder
35
35
/// Gets the maximum capacity of this instance.
36
36
/// </summary>
37
37
/// <value>The maximum number of characters this instance can hold.</value>
38
-
publicintMaxCapacity
39
-
{
40
-
get
41
-
{
42
-
return_maxCapacity;
43
-
}
44
-
}
38
+
publicintMaxCapacity=>_maxCapacity;
45
39
46
40
/// <summary>
47
41
/// Gets or sets the character at the specified character position in this instance.
48
42
/// </summary>
49
43
/// <param name="index">The position of the character.</param>
50
44
/// <returns>The Unicode character at position index.</returns>
45
+
/// <exception cref="IndexOutOfRangeException"><paramref name="index"/> is outside the bounds of this instance while getting a character.</exception>"
46
+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is outside the bounds of this instance while setting a character.</exception>"
51
47
publiccharthis[intindex]
52
48
{
53
49
get
54
50
{
55
-
varchunkPrevious=this;
51
+
StringBuilderchunk=this;
52
+
56
53
while(true)
57
54
{
58
-
varnum=index-chunkPrevious._chunkOffset;
59
-
if(num>=0)
55
+
intindexInBlock=index-chunk._chunkOffset;
56
+
57
+
if(indexInBlock>=0)
60
58
{
61
-
if(num>=chunkPrevious._chunkLength)
59
+
if(indexInBlock>=chunk._chunkLength)
62
60
{
63
61
#pragma warning disable S112// General exceptions should never be thrown
64
62
thrownewIndexOutOfRangeException();
65
63
#pragma warning restore S112// General exceptions should never be thrown
66
64
}
67
-
returnchunkPrevious._chunkChars[num];
65
+
66
+
returnchunk._chunkChars[indexInBlock];
68
67
}
69
-
chunkPrevious=chunkPrevious._chunkPrevious;
70
-
if(chunkPrevious==null)
68
+
69
+
chunk=chunk._chunkPrevious;
70
+
71
+
if(chunk==null)
71
72
{
72
73
#pragma warning disable S112// General exceptions should never be thrown
73
74
thrownewIndexOutOfRangeException();
74
75
#pragma warning restore S112// General exceptions should never be thrown
75
76
}
76
77
}
77
78
}
79
+
78
80
set
79
81
{
80
-
varchunkPrevious=this;
81
-
Label_0002:
82
-
varnum=index-chunkPrevious._chunkOffset;
83
-
if(num>=0)
82
+
StringBuilderchunk=this;
83
+
84
+
while(true)
84
85
{
85
-
if(num>=chunkPrevious._chunkLength)
86
+
intindexInBlock=index-chunk._chunkOffset;
87
+
88
+
if(indexInBlock>=0)
86
89
{
87
-
thrownewArgumentOutOfRangeException("index");
90
+
if(indexInBlock>=chunk._chunkLength)
91
+
{
92
+
#pragma warning disable S3928// Parameter names used into ArgumentException constructors should match an existing one
93
+
thrownewArgumentOutOfRangeException();
94
+
#pragma warning restore S3928// OK to use in .NET nanoFramework context
95
+
}
96
+
97
+
chunk._chunkChars[indexInBlock]=value;
98
+
return;
88
99
}
89
-
chunkPrevious._chunkChars[num]=value;
90
-
}
91
-
else
92
-
{
93
-
chunkPrevious=chunkPrevious._chunkPrevious;
94
-
if(chunkPrevious==null)
100
+
101
+
chunk=chunk._chunkPrevious;
102
+
103
+
if(chunk==null)
95
104
{
96
-
thrownewArgumentOutOfRangeException("index");
105
+
#pragma warning disable S3928// Parameter names used into ArgumentException constructors should match an existing one
106
+
thrownewArgumentOutOfRangeException();
107
+
#pragma warning restore S3928// OK to use in .NET nanoFramework context
97
108
}
98
-
gotoLabel_0002;
99
109
}
100
110
}
101
111
}
@@ -106,72 +116,101 @@ public char this[int index]
106
116
/// <value>
107
117
/// The maximum number of characters that can be contained in the memory allocated by the current instance. Its value can range from Length to MaxCapacity.
/// <exception cref="ArgumentOutOfRangeException">If <see cref="Length"/> is set to a value that is less than zero or greater than <see cref="MaxCapacity"/>.</exception>
0 commit comments