Square Every Digit programming exercise

The math devil is real! But his domain is in trouble. He grows desperate by the minute. For he is cursed and cannot do his homework!!
So please pretty please with a cherry on top, help him! He need a function that will take a integer as an input and then get the sum of every digit squared.

input: 2345
output: 54 //because 2*2 + 3*3 + 4*4 + 5*5 = 54

You can scroll down for the solution of this code problem

  public static int SquareDigits(int n)
//first we need to somehow get all the digits of the number n
//then to square them and sum them
//in this case I am going to convert the integer to string
//with the function held in System ToString()
//that is why we need to transform our digit to string first
//Before we go to go through each digit
//I have to explain that in C# you have to be very careful of the
//data types. Char is not the some as string etc.
//so int.Parse() converts a string (not char) to a number
//that is why we need to transform our digit to string first
//using ToString() again

    string output = ""; 
    foreach (char c in n.ToString())
      int square = int.Parse(c.ToString());
//adding the squared number to "output"
      output += (square * square); 
//returning the result
    return int.Parse(output);