Skip to content

Instantly share code, notes, and snippets.

@jesslilly
Created March 28, 2014 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesslilly/9834554 to your computer and use it in GitHub Desktop.
Save jesslilly/9834554 to your computer and use it in GitHub Desktop.
Just a little C# for a sample problem we white board-ed yesterday
using System;
public class Program
{
public static void Main()
{
Console.WriteLine(wordRepeater("Hi! ",10));
Console.WriteLine(wordRepeater2("Hello! ",10));
}
public static String wordRepeater(String name, int n) {
String output = "";
for (int idx = 0; idx < n; ++idx) {
output += name;
}
return output;
}
public static String wordRepeater2(String name, int n) {
return String.Join(name,new String[n]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment