Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Rastko Đorđević
Published © Apache-2.0

Running Native .NET Core Apps on Raspberry Pi (ARM)

Finally, you can run your .NET Core apps on ARM versions of Ubuntu 16.04, 14.04 and Windows 10 IoT. We'll be making a Pi calculation app.

BeginnerProtip45 minutes31,889
Running Native .NET Core Apps on Raspberry Pi (ARM)

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1

Software apps and online services

Snappy Ubuntu Core
Snappy Ubuntu Core
OS of your choice. Either Ubuntu 16.04, Ubuntu 14.04 or Windows 10 IoT Core.
Windows 10 IoT Core
Microsoft Windows 10 IoT Core
OS of your choice. Either Ubuntu 16.04, Ubuntu 14.04 or Windows 10 IoT Core.
Visual Studio 2015
Microsoft Visual Studio 2015
IDE for making your own .Net Core app. Not required, but recommended if you want to make your own app.

Story

Read more

Code

Program.cs

C#
Code for the Pi calculation program.
using System;
using System.Threading;
namespace picalc
{
    class Program
    {
        static string[] text = {
@"      ___                       ___           ___           ___       ___     ",
@"     /\  \          ___        /\  \         /\  \         /\__\     /\  \    ",
@"    /::\  \        /\  \      /::\  \       /::\  \       /:/  /    /::\  \   ",
@"   /:/\:\  \       \:\  \    /:/\:\  \     /:/\:\  \     /:/  /    /:/\:\  \  ",
@"  /::\~\:\  \      /::\__\  /:/  \:\  \   /::\~\:\  \   /:/  /    /:/  \:\  \ ",
@" /:/\:\ \:\__\  __/:/\/__/ /:/__/ \:\__\ /:/\:\ \:\__\ /:/__/    /:/__/ \:\__\",
@" \/__\:\/:/  / /\/:/  /    \:\  \  \/__/ \/__\:\/:/  / \:\  \    \:\  \  \/__/",
@"      \::/  /  \::/__/      \:\  \            \::/  /   \:\  \    \:\  \      ",
@"       \/__/    \:\__\       \:\  \           /:/  /     \:\  \    \:\  \     ",
@"                 \/__/        \:\__\         /:/  /       \:\__\    \:\__\    ",
@"                               \/__/         \/__/         \/__/     \/__/    " };
        static double Pi = 0;
        static double n = 1;
        static long i = 0L;

        static void Main(string[] args)
        {
            foreach (string s in text)
            {
                Console.WriteLine(s);
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            while (i < long.MaxValue)
            {
                Console.SetCursorPosition(0, Console.CursorTop - 1);
                ClearCurrentConsoleLine();
                Pi += (4.0 / n);
                n += 2.0;
                Pi -= (4.0 / n);
                n += 2.0;
                Console.WriteLine("Generated value of Pi: " + Pi);
                i++;
                Thread.Sleep(50);
            }

        }
        public static void ClearCurrentConsoleLine()
        {
            int currentLineCursor = Console.CursorTop;
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write(new string(' ', Console.WindowWidth));
            Console.SetCursorPosition(0, currentLineCursor);
        }

    }
}

Credits

Rastko Đorđević

Rastko Đorđević

1 project • 10 followers

Comments