Reputation: 12263
I have included iTextSharp in my project to have an ability to create a PDF file. This is my code for this:
Document document = new Document(iTextSharp.text.PageSize.LETTER,20,20,42,35);
PdfWriter writer =
PdfWriter.GetInstance(document,newFileStream("Test.pdf",FileMode.Create));
document.Open();
Paragraph paragraph = new Paragraph("Test");
document.Add(paragraph);
document.Close();
And now the error comes up saying: Font is an ambiguous reference between System.Drawing.Font and iTextSharp.text.Font.
This is the code which is red underlined:
RichTextBox tempBox = new RichTextBox();
tempBox.Size = new Size(650,60);
tempBox.Font = new Font(FontFamily.GenericSansSerif,11.0F); //here is error
flowLayoutPanel1.Controls.Add(tempBox);
Upvotes: 1
Views: 1202
Reputation: 4871
I assume you have these using
directives:
using System.Drawing;
using iTextSharp.text;
Font
is in both namespaces, so it's indeed ambiguous.
You can fully qualify it, to resolve ambiguity:
using System.Drawing;
using iTextSharp.text;
// ...
tempBox.Font = new System.Drawing.Font(FontFamily.GenericSansSerif,11.0F);
Or you can specify an alias:
using System.Drawing;
using Font = System.Drawing.Font;
using iTextSharp.text;
// ...
tempBox.Font = new Font(FontFamily.GenericSansSerif,11.0F);
Upvotes: 6