Attach Variables

I want to take two variables (in and in2) and combine them, for example:

in = 1;
in2 = 3;

pin = in.in2; // I want this to set pin to 13

The Arduino IDE tells me that in is not a class, and what syntax would I use for this?

EDIT: I figured out how to do this, you can just take it in. multiply it by 10 and then set pinto the sum inplusin2

+3
source share
2 answers

If your two variables are definitely integers, then

pin = (in*10)+in2;
would work.

If not, read them in lines (possibly with in.toString (), depending on the language) and just do

pin = int.parse(in.toString()+in2.toString());
(Although, again dependent on language, you may have to do something other than int.parse [in C # you should use int.TryParse () for example])
+1

, C, . , .

pin = int.Parse((string)in + (string)in2);
0

All Articles