1. Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApplication38 {9 class ProgramTen { One Static voidMain (string[] args) A { - intNUM1 =Ten; - intnum2 =Ten; the DoubleNUM3 =10.1; - - stringCStr =string. Concat (NUM1, num2, num3); - + Console.WriteLine (CStr); - + Console.readkey (); A } at } -}
2. Effect
Why can int and double type variables be concatenated together?
Because their parent class is object.
Look at a group of code,
1. Code
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApplication38 {9 class ProgramTen { One Static voidMain (string[] args) A { - intNUM1 =Ten; - intnum2 =Ten; the DoubleNUM3 =10.1; - -Console.WriteLine (NUM1. ToString () +num2. ToString () +num3. ToString ()); - Console.readkey (); + } - } +}
2. Effect
What does the + number in Console.WriteLine have to do with the String.Concat function? You can reverse-compile the tool and take a look.
C # Console Foundation String.Concat connecting multiple int types with double type variables