Skip to content

Instantly share code, notes, and snippets.

@bergpb
Created August 19, 2020 19:46
Show Gist options
  • Select an option

  • Save bergpb/6eadcf9bd01e5f3dc01e328437cc6049 to your computer and use it in GitHub Desktop.

Select an option

Save bergpb/6eadcf9bd01e5f3dc01e328437cc6049 to your computer and use it in GitHub Desktop.
Outro exemplo de Extension Methods no C#
using System
public class ProcessFile
{
public static void Main()
{
string s1 = "Good morning dear students";
Console.WriteLine(s1.Cut(0));
}
}
namespace System
static class StringExtensions
{
public static string Cut(this string thisObj, int count)
{
if(thisObj.Lenght <= count)
{
return thisObj;
}
else
{
return thisObj.Substring(0, count) + "...";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment