I am learning c# and I want to find out whether the 3rd bit in an integer is a 1 or 0.
So how I am approaching this is to convert the int to a binary. Then convert the string to an array. convert the array of string to an array of ints and slice on the 3rd bit and check value.
I cannot quite get this to happen. This is where I am at. I am using this example from SO to convert to array
using System;
using System.Text;
class Expression
{
static void Main()
{
int number = 3;
string binValue = Convert.ToString(number, 2);
char[] array = binValue.ToCharArray();
array<int> list = new List<int>();
for (int i = 0; i < array.Length; i++)
{
list.add(value);
}
int[] binArr = list.ToArray();
binArr[2] == 1? "Yes" : "No";
}
}