Created
June 11, 2019 20:23
-
-
Save danielpetisme/aa789fa70bcd0e5db2aac00018be0c5f to your computer and use it in GitHub Desktop.
.Net Method Extensions
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
public static class StringExtension | |
{ | |
public static string Capitalize(this string str) { | |
return char.ToUpper(str[0]) + str.Substring(1); | |
} | |
public static string Decorate(this string str, string decoration) => $"{decoration} {str} {decoration}"; | |
} | |
public class Program | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine("java".Capitalize()); | |
Console.WriteLine("Java + C#".Decorate("🧡")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment