I know that there are combinatoric libraries for this kind of thing. However, with me being new to C# and coding in general I found that I couldn't understand the code well enough to implement it in my solution.Here is the challenge:Given two integers: L and R,find the maximal values of A xor B given, L  A  B  RInput Format  The input contains two lines, L is present in the first line.  R in the second line.Constraints  1  L  R  103Output Format  The maximal value as mentioned in the problem statement.Sample Input#00 1 10Sample Output#0015Sample Input#011015Sample Output#017 Explanation for the second example is as follows:In the second sample let's say L=10, R=15, then all pairs  which comply to above condition are 1010=0   1011=1  1012=6  1013=7  1014=4  1015=5  1111=0  1112=7  1113=6  1114=5   1115=4  1212=0  1213=1  1214=2  1215=3   1313=0  1314=3  1315=2  1414=0  1415=1   1515=0 Here two pairs (10,13) and (11,12) have maximum xor value 7 and this  is the answer.The code below represents my solution to the problem in question. It works but I feel like I reinvented the wheel on this one. Is there a better way of going about it than what I have?using System;using System.Collections.Generic;using System.IO;using System.Linq;class Solution {    public static List<int[]> Combinations( List<int> number_list )     {        // We are only choosing 2 values out of any list of numbers        int[] TwoList = new int[2];         List<int[]> result = new List<int[]>();        List<int> stack = new List<int>(number_list);                            while (stack.Count > 0)         {            int StackLast = stack.Count - 1;            for (int i =0; i < stack.Count; i++)             {                TwoList[0] = stack[StackLast];                TwoList[1] = stack[i];                result.Add(new int[] {TwoList[0], TwoList[1]});            }            stack.RemoveAt(StackLast);        }        return result;    }    static int MaxXor(int l, int r)     {        List<int> NumList = new List<int>(Enumerable.Range(l, r - l + 1));        // Inserts the list combinations as int arrays        List<int[]> comboList = Combinations(NumList);         int max = 0;        foreach(var two in comboList)        {            int XorValue = two[0] ^ two[1];            max = ( max > XorValue )? max : XorValue;        }        return max;    }    static void Main(String[] args)     {        int _l;        int _r;        _l = Convert.ToInt32(Console.ReadLine());        _r = Convert.ToInt32(Console.ReadLine());        Console.WriteLine(MaxXor(_l, _r));    }}
Maximizing XOR HackerRank challenge
c#;algorithm;programming challenge
Couple of basic things with C#Don't use Egyptian style Bracing, that's for Java.Watch your indentation, I fixed it in the question.Casing should follow basic C# standardsPascalCase for all Methods, Constants, and Property namescamelCase for everything elseProtected and public instance variables are UpperCamelCase (to avoid confusion with 3.2) as Jeroen commented You have more than enough newlines in the code, this can be distracting in your code.From what I see of your Comments they are all unneededold code should be deletedother comments are not needed to explain the flow of code or the purpose of the code because it is apparent what is going on with your code.With these Variables I am not sure what was meant by the Underscore on them, they don't look private or look like properties, they should have a more meaningful name as well   int _l;   int _r;   // We are only choosing 2 values out of any list of numbers   int[] two_list = new int[2];This seams like a waste of time to me, you want two numbers, not an array of numbers and not a list of numbers, so you should have two numbers.int number1;int number2;and these numbers should not be written outside of the double loop, this brings me to the conclusion that they are not needed at all, and that you should write this:        for (int i =0; i < stack.Count; i++) {            two_list[0] = stack[stackLast];            two_list[1] = stack[i];            result.Add(new int[] {two_list[0], two_list[1]});        }instead like thisfor (int i =0; i < stack.Count; i++) {    result.Add(new int[] {stack[stackLast], stack[i]});}