Link to home
Start Free TrialLog in
Avatar of r3nder
r3nderFlag for United States of America

asked on

convert long to string using as

I am trying to convert a long value to a string - I keep getting the error "the as operator must be used with a reference type" how do I fix this

int number;
                    int thiscontroller = int.TryParse(myBus.Controller_EEProm[EEPROM.CONTROLLER.SerialNum].Data as long,number);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of r3nder

ASKER

sorry there is an error cannot convert 'bus.busbuffer' to long
if I specify  it as long I get 1095
Avatar of r3nder

ASKER

I am trying to convert myBus.Controller_EEProm[EEPROM.CONTROLLER.SerialNum].Data as long this gives me 1095
myBus.Controller_EEProm[EEPROM.CONTROLLER.SerialNum].Data gives me 'mybus.busBuffer'
What is the datatype of bus.busbuffer?  *Most likely it is a byte array.*

-saige-
Avatar of r3nder

ASKER

it is a struct
public struct BusBuffer
        {
            public float asfloat;
            public uint asLong;
            public int assignedLong;
            public short assignedshort0;
            public short assignedshort1;
            public ushort asunsignedshort0;
            public ushort asunsignedshort1;
            public byte Byte0;
            public byte Byte1;
            public byte Byte2;
            public byte Byte3;
Avatar of r3nder

ASKER

I feel like an idiot - not as long it is a name aslong - thnks anyway it
Avatar of r3nder

ASKER

Thanks it - sorry for the inconvinience
Not a problem.

-saige-