Post Reply 
 
Thread Rating:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass floats as string literals to a method
12-14-2010, 08:30 AM
Post: #1
Pass floats as string literals to a method
returns "Incompatible type for constructor. Explicit cast needed to convert double to int." even if the constructor Color (float r, float g, float b) is valid. That's because the compiler interprets numbers like 0.1 as double not float. You must use the suffixe "f" to indicate that the number is a float.

Color c = new Color(0.1f,0.2f,0.4f);
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:



Send your comments, Suggestions or Queries regarding this site at info@tutorials4u.net

Copyright © 2010 Tutorials4u.net All Rights Reserved