First of all, I’d like to apologize if there is any issue with my question.
I don’t really understand why my code is printing out the correct position.
When I call Console.WriteLine($“Song number {index} is rated three stars”); shouldn’t the code need {position} instead of {index}?
I don’t undertsand why index has 1 being added to it…
using System;
namespace BuiltInMethods
{
class Program
{
static void Main(string[] args)
{
string[] summerStrut;
summerStrut = new string[] { "Juice", "Missing U", "Raspberry Beret", "New York Groove", "Make Me Feel", "Rebel Rebel", "Despacito", "Los Angeles" };
int[] ratings = { 5, 4, 4, 3, 3, 5, 5, 4 };
int index = (Array.IndexOf(ratings, 3));
int position = index++;
int threeStars = Array.Find(ratings, three => three == 3);
Console.WriteLine($"Song number {index} is rated three stars");
}
}
}