Ternary Statement With DrawTextValuePair

41 views Asked by At

I am getting an error thrown when the text box value is null, so I was trying to write a ternary statement to check if the value is null. This is what I cam up with:

DrawTextValuePair(e, string.IsNullOrEmpty(m_pcl.pn.Text) ? String.Format("Input: ", m_pcl.pn.Text) : String.Format("Input: "), true, m_leftMargin);

But in using such I get a compile error of:

There is no argument given that corresponds to the required formal parameter 'iLeftMargin' of 'ProfileDocument.DrawTextValuePair(PrintPageEventArgs, string, string, bool, int)'

What would be the proper way to utilize a ternary statement in this instance?

1

There are 1 answers

6
Dmitry On BEST ANSWER

The method

ProfileDocument.DrawTextValuePair(PrintPageEventArgs, string, string, bool, int)

expects 5 arguments, but you provided it with only 4:

DrawTextValuePair(
    e, // 1st
    string.IsNullOrEmpty(m_pcl.pn.Text) ? String.Format("Input: ", m_pcl.pn.Text) : String.Format("Input: "), // 2nd
    true, // 3rd
    m_leftMargin // 4th
);