Created
March 28, 2014 14:48
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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