BorislavBorisov

! Запис на цифрите на int в List<char>

Sep 27th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class StringToInt
  4. {
  5.     static void Main()
  6.     {
  7.         int a = 3456;
  8.         GetNumber(a);
  9.            
  10.     }
  11.     static void GetNumber(int a)
  12.     {
  13.         List<char> list = new List<char>();
  14.  
  15.         for (int i = 0; i < 4; i++)
  16.         {
  17.             int number = a % 10; ;
  18.             string digitStr = "" + number;
  19.             char digitch = digitStr[0];
  20.             list.Insert(0, digitch); //Insert() - подрежда числата правилно в листа
  21.             a /= 10;
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment