I used extension methods many times and did not come across this problem. Anyone have any ideas why this is causing the error?
/// <summary> /// Rounds the specified value. /// </summary> /// <param name="value">The value.</param> /// <param name="decimals">The decimals.</param> /// <returns></returns> public static decimal Round (this decimal value, int decimals) { return Math.Round(value, decimals); }
Using:
decimal newAmount = decimal.Parse("3.33333333333434343434"); this.rtbAmount.Text = newAmount.Round(3).ToString();
newAmount.Round (3) throws a compiler error:
Error 1 Member 'decimal.Round(decimal)' cannot be accessed with an instance reference; qualify it with a type name instead
mservidio
source share