Problem with implicit conversion of double to float

I have some C# code that is using doubles for coordinate values that are passed to graphics functions such as:

DrawLine (Pen, x1,y1,x2,y2)

where x1, etc are all declared as double, while the methood is defined as

public void DrawLine (
      Pen pen,
      float x1,
      float y1,
      float x2,
      float y2

I haven't been able to get this to compile, as I get an error:

Error      2      Argument '1': cannot convert from 'double' to 'float'

I assume this a problem with either the compiler options (to allow the implicit narrowing) or the library (is there are "double" version of System.Drawing.Graphics?
(Using Visual Studio C# 2005 Express compiler)
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Raynard7Connect With a Mentor Commented:

There is not - however you should be able to use System.Convert.ToSingle()
because with c# float is an alias for single
C# is a type safe language, try this

DrawLine (Pen, (float)x1,(float)y1,(float)x2,(float)y2)
Or, if that does not work then

DrawLine (Pen, System.Convert.ToSingle(x1),System.Convert.ToSingle(y1),System.Convert.ToSingle(x2),System.Convert.ToSingle(y2));
All Courses

From novice to tech pro — start learning today.