Tuesday, 15 March 2016

C# Code Snippets

Return number only from text
private string GetNumbers(string input)
{
    return new string(input.Where(c => char.IsDigit(c)).ToArray());
}


Read CSV file

static List ReadCSV(string filename)
{
  return File.ReadLines(filename)
          //.Skip(1)
          .Where(s => s != "")
          .Select(s => s.Split(new[] { ',' }))
          .Select(a => new Result
           {
              OrgFN = a[0],
              NewFN = a[2],
              Barcode = a[1]
           })
           .ToList();
}



Or can use this:
http://www.codeproject.com/Articles/12170/FileHelpers-v-Delimited-CSV-or-Fixed-Data-Impor

Saturday, 12 March 2016

Install Mono and MonoDevelop

Add additional package repositories. First add the Mono Project GPG signing key by typing in the (remote or local) command prompt
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

Then type
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
for the first repository. Now enter
echo "deb http://download.mono-project.com/repo/debian wheezy-apache24-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
for the second repository.
Once added, we need to execute the sudo apt-get update and sudo apt-get upgrade commands again. Cool, now we are finally ready to install Mono: enter
sudo apt-get install mono-complete

When prompted hit enter or Y to confirm the installation of the complete Mono framework. Give it some time to complete, it takes like 5 minutes.

Link