Kuzo
Kuzo
CC#
Created by Kuzo on 10/31/2023 in #help
✅ [Fixed]Class function wont output anything
c#
namespace DecToBin
{
public class BinClass
{

int Dec;
public int[] array = new int[8];
public BinClass(int Decim)
{ Dec = Decim; }

public void BinGet()
{
for (int a = 0; a < 8; a++)
{
array[a] = Dec % 2;
Dec = Dec / 2;
}
}

public void BinWrite()
{
for(int a=7; a<=0; a--)
{
Console.Write(array[a]);
wspace(a);
}
}

public void wspace(int x)
{
if (x % 4 == 0)
{
Console.Write(" ");
}
}

}
}
c#
namespace DecToBin
{
public class BinClass
{

int Dec;
public int[] array = new int[8];
public BinClass(int Decim)
{ Dec = Decim; }

public void BinGet()
{
for (int a = 0; a < 8; a++)
{
array[a] = Dec % 2;
Dec = Dec / 2;
}
}

public void BinWrite()
{
for(int a=7; a<=0; a--)
{
Console.Write(array[a]);
wspace(a);
}
}

public void wspace(int x)
{
if (x % 4 == 0)
{
Console.Write(" ");
}
}

}
}
c#
using DecToBin;
using System.Dynamic;

namespace Bin
{

class Binary
{
static void text(string txt)
{
Console.WriteLine(txt + Environment.NewLine);
}
static void Main(string[] args)
{
int[] BinA=new int[8];
text("Input Decimal Number");
int dec=Convert.ToInt32(Console.ReadLine());
DecToBin.BinClass Bin = new BinClass(dec);
Bin.BinGet();
Bin.BinWrite();

}
}
}
c#
using DecToBin;
using System.Dynamic;

namespace Bin
{

class Binary
{
static void text(string txt)
{
Console.WriteLine(txt + Environment.NewLine);
}
static void Main(string[] args)
{
int[] BinA=new int[8];
text("Input Decimal Number");
int dec=Convert.ToInt32(Console.ReadLine());
DecToBin.BinClass Bin = new BinClass(dec);
Bin.BinGet();
Bin.BinWrite();

}
}
}
21 replies