37 lines
616 B
Plaintext
37 lines
616 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
public void DoSomething(string[] strings)
|
|
{
|
|
for (int i = 0; i < strings.Length; i--) // Noncompliant
|
|
{
|
|
string s = strings[i]; // IndexOutOfRangeException when i reaches -1
|
|
// do stuff
|
|
}
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
public void DoSomething(string[] strings)
|
|
{
|
|
for (int i = 0; i < strings.Length; i++)
|
|
{
|
|
string s = strings[i];
|
|
// do stuff
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|