[Mono-list] how to use 'Conversions.ToInteger' in mono?

Rolf Bjarne Kvinge rolflists at ya.com
Sat Jun 21 06:24:26 EDT 2008


> 
> Hey guys.
> I am trying, for the first time, to port a win c# application to a
> linux
> system.
> The code is used to access a usb sensor that acts as a rs-232 device,
> so I figured out that it is something doable even on linux.
> But I also need to perform a binary->decimal conversion.
> 
> When working in MS environment I just used
> Microsoft.VisualBasic.CompilerServices which, AFAIK, isn't available in
> mono

Yes it is.
You need to install the mono-basic package.

Rolf

.
> The function I need to port is:
> 
> private static double Bin2Dec(String strBin)
>         {
>             try
>             {
>                 double lDec = 0.0;
>                 if (strBin == null || strBin.Length == 0)
>                     strBin = "0";
>                 double lCount = Strings.Len(strBin);
>                 double t_double = lCount;
>                 for (double i = 1.0; i <= t_double; i++)
>                 {
>                     lDec += Conversions.ToInteger(Strings.Left(strBin,
> 1))
> * Math.Pow(2.0, (double)(Strings.Len(strBin) - 1));
>                     strBin = Strings.Right(strBin, Strings.Len(strBin)
> - 1);
>                 }
>                 return lDec;
>             }
>             catch (Exception) { }
> 
>             return double.MinValue;
>         }
> 
> 
> Anyone has any suggestions on how to implent this in a way that works
> on
> linux?
> Thanks
> 
> Josh
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> No virus found in this incoming message.
> Checked by AVG.
> Version: 8.0.100 / Virus Database: 270.4.1/1511 - Release Date:
> 20/06/2008 11:52



More information about the Mono-list mailing list