ASP.NET C# error: Operator * cannot be applied to operands of type 'int' and 'string' -


Forgive me, I'm starting a new one, but I'm making a basic "change from Fahrenheit to Celsius" program I can not understand the above error, my code looks like this:

  & lt;% @ page language = "c #"%> & Lt ;! DOCTYPE html & gt; & Lt; Script runat = "server" & gt; Protected Zero Button 1_Click (Object Sender, EventArgs E) {Double Fahrenheit = Double. Purse (farTemp.Text); LblCelsius.Text = (5/9) * (Fahrenheit-32). Ostring (); } & Lt; / Script & gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Head id = "head1" runat = "server" & gt; & Lt; Title & gt; Convert temperature & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Div & gt; Enter the temperature in the Fahrenheit degree: & amp; Nbsp; & Amp; Nbsp; & Lt; ASP: Text Box Width = "75" id = "farTemp" Runt = "Server" /> & Lt; Br / & gt; & Lt; Br / & gt; & Lt; ASP: Button ID = "Button 1" text = "Change to Celsius" OnClick = "Button1_Click" Runat = "server" /> & Lt; / Div & gt; & Lt; Br / & gt; & Lt; Div & gt; Degrees in Celsius: & lt; ASP: label ID = "LBL Celsius" runat = "server" /> & Lt; Br / & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt; Error 7 appears in line. The strange thing is, when I change the symbol '*' in the symbol '+', then the program works (except for the fact that it does this wrong math) what is any idea going on?   

Your bracket is in the wrong place, you're fahrenheit - 32, convert it to a string Afterwards, it is trying to multiply. Try it:

  lblCelsius.Text = ((5/9) * Fahrenheit - 32) .ostring ();    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -