rspec/rules/S2251/csharp/rule.adoc

30 lines
475 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
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
}
}
----
include::../see.adoc[]