How to append int to int in C#

4 Answers

0 votes
using System;

class Program
{
    static void Main() {
        int a = 10; 
        int b = 938; 
        
        int newNumber = int.Parse(a.ToString() + b.ToString());

        Console.WriteLine(newNumber);
    }
}
   
   
   
   
/*
run:
      
10938
    
*/

 



answered Oct 18, 2023 by avibootz
0 votes
using System;

class Program
{
    static void Main() {
        int a = 10; 
        int b = 938; 
        
        int newNumber = Convert.ToInt32(string.Format("{0}{1}", a, b));

        Console.WriteLine(newNumber);
    }
}
   
   
   
   
/*
run:
      
10938
    
*/

 



answered Oct 18, 2023 by avibootz
0 votes
using System;
 
class Program
{
    static void Main() {
        int a = 10; 
        int b = 938; 
         
        a = int.Parse(a.ToString() + b.ToString());
 
        Console.WriteLine(a);
    }
}
    
    
    
    
/*
run:
       
10938
     
*/

 



answered Oct 19, 2023 by avibootz
0 votes
using System;
 
class Program
{
    int concatenate(int x, int y) {
        int pow = 10;
        
        while(y >= pow)
            pow *= 10;
            
        return x * pow + y;        
    }
    static void Main() {
        int a = 10; 
        int b = 938; 
         
        a = int.Parse(a.ToString() + b.ToString());
 
        Console.WriteLine(a);
    }
}
    
    
    
    
/*
run:
       
10938
     
*/

 



answered Oct 19, 2023 by avibootz

Related questions

1 answer 134 views
1 answer 189 views
1 answer 190 views
1 answer 200 views
200 views asked Apr 26, 2017 by avibootz
1 answer 173 views
1 answer 161 views
161 views asked Jan 16, 2017 by avibootz
1 answer 178 views
178 views asked Jan 16, 2017 by avibootz
...