Remove trailing space left at the end of the binary string
This commit is contained in:
@@ -48,10 +48,7 @@ namespace WindowsFormsApplication1
|
||||
decimalNum = long.Parse(decimalTextBox.Text);
|
||||
hexNum = Convert.ToInt64(hexTextBox.Text, 16);
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
//if (spacingToggle.Checked)
|
||||
//{
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
//}
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
binNum = Convert.ToInt64(binaryTextBox.Text, 2);
|
||||
octalNum = Convert.ToInt64(octalTextBox.Text, 8);
|
||||
paddingOffset = int.Parse(paddingOffsetTextBox.Text);
|
||||
@@ -131,11 +128,18 @@ namespace WindowsFormsApplication1
|
||||
var builder = new StringBuilder(binaryString); // String builder
|
||||
while (i != 0)
|
||||
{
|
||||
if (i % spacingOffset == 0) // If i mod spacingOffset equals zero, append a space to the offset specified by i.
|
||||
if (!(i == binarySize)) // Get rid of trailing space
|
||||
{
|
||||
builder.Insert(i, " ");
|
||||
if (i % spacingOffset == 0) // If i mod spacingOffset equals zero, append a space to the offset specified by i.
|
||||
{
|
||||
builder.Insert(i, " ");
|
||||
}
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
i--;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
binaryTextBox.Text = builder.ToString();
|
||||
builder = null; // null out builder when done
|
||||
|
Reference in New Issue
Block a user