Skip to content

Instantly share code, notes, and snippets.

@jerone
Created January 22, 2013 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerone/4595989 to your computer and use it in GitHub Desktop.
Save jerone/4595989 to your computer and use it in GitHub Desktop.
Insert char at index in char array (in this case a number)
using System;
using System.Windows.Forms;
namespace Script
{
public class Script
{
public void Main()
{
int no = 52123456;
char[] c = no.ToString().ToCharArray();
char[] buffer = new char[c.Length + 1];
for (int i = 0, ii = 0; i < c.Length; i++)
{
if (i == 2)
{
buffer[i] = '.';
}
else
{
buffer[i] = c[ii];
ii++;
}
}
String result = new String(buffer);
MessageBox.Show(result);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment