levelizard
New member
- Joined
- Oct 26, 2020
- Messages
- 2
- Programming Experience
- 1-3
Hi,
I am a beginner with C# and I am doing a task in VS, trying to execute the following code, there are no errors but it still does not build successfully:
Does someone have an idea how to run it? Thank you in advance.
I am a beginner with C# and I am doing a task in VS, trying to execute the following code, there are no errors but it still does not build successfully:
C#:
namespace ConsoleApp1
{
using System;
using System.Linq;
public class Program
{
public int[] SwitchLights(int[] a)
{
var count = a.Count(t => t == 1);
for (int i = 0; i < a.Length; i++)
{
var current = count;
if (a == 1) count--;
if (current % 2 == 1) a = a == 1 ? 0 : 1;
}
return a;
}
}
}
Last edited by a moderator: