Create a function that returns the sum of the ASCI-value of each char in the given string.
using System;
namespace Solution{
public class ToAsci
{
public static int getAsciSum(string s)
{
int returner = 0;
foreach (var el in s)
returner += (int)el;
return returner;
}
}
}
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD development by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void MyTest()
{
Assert.AreEqual(448, ToAsci.getAsciSum("test"));
Assert.AreEqual(97, ToAsci.getAsciSum("a"));
Assert.AreEqual(2286, ToAsci.getAsciSum("Some Words and numbers 453"));
Assert.AreEqual(730, ToAsci.getAsciSum("&@Sp15, R@m"));
}
}
}