B2B-Training/Iteration/Recursion.cs
Louis de2eb52756
All checks were successful
Tests / Unit Testing1 (push) Successful in 43s
feat: Finish Iteration
2023-11-02 18:23:52 +01:00

35 lines
723 B
C#

namespace Iteration;
public class Recursion
{
public static bool IsAlphanum(string s, int i)
{
if (i >= s.Length)
{
return true;
}
else
{
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= '0' && s[i] <= '9'))
{
return IsAlphanum(s, i + 1);
}
else
{
return false;
}
}
}
public static string ReverseStr(string source, int lenght)
{
if (lenght == 0)
{
return "";
}
else
{
return source[lenght - 1] + ReverseStr(source, lenght - 1);
}
}
}