Search code examples
c#model-view-controllerpdfsharp

How to change PdfSharp controller after changing a int to a decimal


I changed my int to decimal? and I am now getting a error in my PdfSharp controller

gfx.DrawString(job.JobRetainage.ToString("C",
              new System.Globalization.CultureInfo("en-US")), BodyFont, XBrushes.Black,
             new XRect(460, 160, page.Width, page.Height),
             XStringFormats.TopLeft);

Error Message

no overload for method tostring takes 2 arguments


Solution

  • Try this:

    gfx.DrawString(job.JobRetainage.Value.ToString("C",
              new System.Globalization.CultureInfo("en-US")), BodyFont, XBrushes.Black,
             new XRect(460, 160, page.Width, page.Height),
             XStringFormats.TopLeft);
    

    You would also want to check for null or use GetValueOrDefault().