Skip to content

Instantly share code, notes, and snippets.

@danielpetisme
Created June 11, 2019 20:23
Show Gist options
  • Save danielpetisme/aa789fa70bcd0e5db2aac00018be0c5f to your computer and use it in GitHub Desktop.
Save danielpetisme/aa789fa70bcd0e5db2aac00018be0c5f to your computer and use it in GitHub Desktop.
.Net Method Extensions
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