question

abdullah-3512 avatar image
0 Votes"
abdullah-3512 asked YijingSun-MSFT answered

where is the problem in function?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp21
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public double Sasd(double s,double y)
{if (radioButton1.Checked == true)
{
double e = Math.Pow(s, y)/(s*y);

             return e;


            
            
         }

         else (radioButton2.Checked == true){

             double o = s * y;

             return o;

         }






     }
     private void button1_Click(object sender, EventArgs e)
     {
         double s = Convert.ToDouble(textBox1.Text);

         double y = Convert.ToDouble(textBox2.Text);
         label3.Text = Sasd(s, y).ToString();


     }
 }

}

dotnet-aspnet-webforms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KamleshKumar avatar image
0 Votes"
KamleshKumar answered

Hi @abdullah-3512 ,

Thank you for asking this question on the Microsoft Q&A Platform.

Seems you are missing some piece of code also check the else condition, Try to update the below code and see the result.

         public double Sasd(double s, double y)
         {
             if (radioButton1.Checked == true)
             {
                 double e = Math.Pow(s, y) / (s * y);
                 return e;
             }
             else if (radioButton2.Checked == true)
             {
                 double o = s * y;
                 return o;
             }
             else
             {
                 double t=0;
                 return t;
             }
         }

Regards,
Kamlesh Kumar
BizTalk Techie


Please don't forget to click on 205836-130616-image.png or upvote 205759-130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is How

Want a reminder to come back and check responses? Here is how to subscribe to a Notification

If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered

Hi @abdullah-3512 ,
First, you have wrong with if else. And then you need return the value in the Sasd method.

 private void button1_Click(object sender, EventArgs e)
         {
             double s = Convert.ToDouble(textBox1.Text);
             double y = Convert.ToDouble(textBox2.Text);
             label3.Text = Sasd(s, y).ToString();
         }
         public double Sasd(double s, double y)
         {
             double x = 0;
             if (radioButton1.Checked == true)
             {
                 double e = Math.Pow(s, y) / (s * y);
                 x= e;
             }
             else if (radioButton2.Checked == true){
                 double o = s * y;
                 x=o;
             }
             return x;
         }

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.