Hi all!
I have just started out to learn programming for the first time and am an absolute noob.
I ran into a question from a simple assignment in Vystavel's C# Programming for absolute beginners, regarding different ways of putting numbers together.
I'm in the standard VS Console App C# (.NET Framework) environment:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
ex. 1:
Console.WriteLine("a) " + 1 + 1);
results in a) 11. I understand why.
ex. 2:
Console.WriteLine("b) " + (1 + 1));
results in b) 2. Again, I understand why.
But what if I want the result of 1 + 1 to be the number 11 without prefacing it with text like in example 1?
So, having the 1's string together to 11 instead of adding up to 2?
(if I understood correctly, doing ("1" + "1") will result in text, as will ("11"), instead of a number)
I have just started out to learn programming for the first time and am an absolute noob.
I ran into a question from a simple assignment in Vystavel's C# Programming for absolute beginners, regarding different ways of putting numbers together.
I'm in the standard VS Console App C# (.NET Framework) environment:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
ex. 1:
Console.WriteLine("a) " + 1 + 1);
results in a) 11. I understand why.
ex. 2:
Console.WriteLine("b) " + (1 + 1));
results in b) 2. Again, I understand why.
But what if I want the result of 1 + 1 to be the number 11 without prefacing it with text like in example 1?
So, having the 1's string together to 11 instead of adding up to 2?
(if I understood correctly, doing ("1" + "1") will result in text, as will ("11"), instead of a number)