I am very new to MS VS12 and I'm working a class project that requires me to convert a Base 10 number to Bases 2, 3, 8, and 16. It also asks me to put the conversion in a method and then call those methods using buttons and I am not sure how to get started. Can anyone help me?!
Here is what I have so far (taken some of this from Quickest way to convert a base 10 number to any base in .NET?)
public static string IntToBinary(int value, char[] basechars)
{
string binary = IntToBinary(16, new char[] { '0', '1' });
string hex = IntToBinary(16, new char[] { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'});
string result = string.Empty;
int conversion = basechars.Length;
do
{
result = basechars[value % conversion] + result;
value = value / conversion;
}
while (value > 0);
return result;
}
I have 5 buttons. A generic 'Convert' that takes a number from a textbox and then a base number (2-16) from another textbox and once the 'Convert' button is clicked it convert the number to the base number that was specified. The other buttons are: Base2, Base3, Base8, Base16. I have to write methods for each of those conversions and call them from their specified buttons
I have to call the methods that pertains to the buttons.