Skip to content

Instantly share code, notes, and snippets.

@Vitosh
Created May 8, 2019 20:47
Show Gist options
  • Save Vitosh/205df10b7eb69f851154b909f72fd9c9 to your computer and use it in GitHub Desktop.
Save Vitosh/205df10b7eb69f851154b909f72fd9c9 to your computer and use it in GitHub Desktop.
using System;
namespace Hanna
{
class Startup
{
static void Main()
{
String input = "12.12.2222";
int[] x = { 0, 0, 0 };
int dateWhich = 0;
string currentNumber = "";
string numberToCheck = "";
for (int i = 0; i < input.Length; i++)
{
currentNumber = input[i].ToString();
if (currentNumber != ".")
{
numberToCheck = string.Concat(currentNumber, numberToCheck);
}
else
{
//Convert.ToInt32 - v Java e valueOf()
x[dateWhich] = Convert.ToInt32(Reverse(numberToCheck));
numberToCheck = "";
dateWhich++;
}
}
x[dateWhich] = Convert.ToInt32(Reverse(numberToCheck));
}
public static string Reverse(string s)
{
char[] charArray = s.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment