Hello, i have a problem with my. I'm a beginner in C# so take me easy.

I need to use an integer wich varies from 0 to 255 (trackbar). I don't know how to match the integer with the address of respective char (actually serialPort1 uses string to send) in order to send it via rs232.

Recommended Answers

All 3 Replies

Hi andutzicus, welcome.
Don't know exactly what you mean with your problem. Do you want an int converted to binary?
To convert an int to a string you could do something like this: MyString S = 42.ToString();
S would now contain the string "42".

Possibly this is what you mean?

        Int32 i = 255;
        char c = (char)i;
        // or 
        string s = new string(c,1);

I'm sorry, it was late and i thnk it wasn't my best explanation. Let's assume that trackbar value is 103. Now, the string that i want to be sent is "g" wich is the correspondent in decimal. When i'll have the char correct i will concatenate char to an empty string and send it via serial port.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.