Newbie question int

Hello guys.
I have an unusual problem. I would like my int to add value in this way:

public int myInt = 0;
public int secondInt = 1;
public int thirdInt = 2;

void MyVoid(){
myInt = secondInt += thirdInt;
}

I wish my int was 12, like in string, not 3.

How can i do this? Anyone can help me?

Greetings.

You can convert to strings, combine, then parse back:

myInt = int.Parse($"{secondInt}{thirdInt}");

If secondInt and thirdInt are <10, you could do this through simple math:

myInt = secondInt * 10 + thirdInt;
1 Like

I think something like this should work:

public int myInt = 0;
public int secondInt = 1;
public int thirdInt = 2;
string ConcatinatedNumber = "";

void MyVoid(){
ConcatinatedNumber = secondInt.ToString() + thirdInt.ToString();
myInt = Int32.Parse(ConcatinatedNumber);
}
2 Likes

Can you tell me if any offer can be released during a specific hour? Eg at 2pm debug log will say something?

Its work! I love You mate! :smile: