Page MenuHomePhabricator

(An Untitled Masterwork)
ActivePublic

Authored by stwalkerster on Jun 15 2016, 2:55 AM.
Tags
None
Referenced Files
F856:
Jun 15 2016, 2:55 AM
Subscribers
None
// Let's have a class. It's sealed for some reason so we can't extend it.
public sealed class Foo
{
// This class has two properties, but has nothing useful here.
public int Value1 {get;set;}
public int Value2 {get;set;}
}
// let's say I want to add the two numbers together. Because this is a Complicated Operation (tm), I'm gonna write an extension method to do it.
public static class HandyStuff
{
public static int SumThings(this Foo x)
{
return x.Value1 + x.Value2;
}
}
// let's get an instance...
var foo = new Foo { Value1 = 3, Value2 = 4 };
// Now, I can do stuff like this:
var result = foo.SumThings();

Event Timeline

stwalkerster updated the paste's language from autodetect to csharp.
import-bot changed the edit policy from "All Users" to "Community (Project)".Feb 3 2017, 3:03 PM