Skip to content

Instantly share code, notes, and snippets.

@GhostTW
Created January 9, 2020 14:50
Show Gist options
  • Save GhostTW/bae9c6b000db9193dd8600e18083c26f to your computer and use it in GitHub Desktop.
Save GhostTW/bae9c6b000db9193dd8600e18083c26f to your computer and use it in GitHub Desktop.
void Main()
{
PriceA.Dump("A");
PriceB.Dump("B");
PriceC.Dump("C");
"---".Dump("GetPriceA()");
ref decimal price = ref GetPriceA();
PriceA.Dump("A");
(++price).Dump("price++");
PriceA.Dump("A");
"---".Dump("GetPriceB()");
price = GetPriceB();
price.Dump("price");
PriceA.Dump("A");
PriceB.Dump("B");
(++price).Dump("price++");
PriceA.Dump("A");
PriceB.Dump("B");
"---".Dump("ref GetPriceC()");
price = ref GetPriceC();
price.Dump();
PriceA.Dump("A");
PriceB.Dump("B");
PriceC.Dump("C");
(++price).Dump("price++");
PriceA.Dump("A");
PriceB.Dump("B");
PriceC.Dump("C");
}
private decimal PriceA = 199;
private decimal PriceB = 99;
private decimal PriceC = 9;
public ref decimal GetPriceA()
{
return ref this.PriceA;
}
public decimal GetPriceB()
{
return this.PriceB;
}
public ref decimal GetPriceC()
{
return ref this.PriceC;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment