What's new

C# Help, hirap ng online class

Status
Not open for further replies.

shion_

Eternal Poster
Established
Joined
Apr 28, 2016
Posts
1,171
Reaction
380
Points
462
Paano po ito lalagyan ng return value?
 

Attachments

Panong return value ts, ano ginagawa mo diyan sa VS Studio? Calculator ba yan? Give us some context para matulungan ka namin.
 
Panong return value ts, ano ginagawa mo diyan sa VS Studio? Calculator ba yan? Give us some context para matulungan ka namin.
Mag input po ng numbers tapos ilalabas nya yung highest and lowest sa na input
 
Kung 3 values lang yan baka puwedeng ganito na lang (not tested):
C#:
int highest = 0;
if (value1 >= value2) {
 if (value1 >= value3){
  highest = value1;
else {
  highest = value3;
 }
}
else{
 if (value2 >= value3){
  highest = value2;
else {
  highest = value3;
 }
}
 
Ano bang gusto mong mangyari? rereturn kung anong max value? sa 3 given values?
USER_SCOPED_TEMP_DATA_photo1630591818767_6839197787823899808.jpeg
 

Attachments

Kung 3 values lang yan baka puwedeng ganito na lang (not tested):
C#:
int highest = 0;
if (value1 >= value2) {
 if (value1 >= value3){
  highest = value1;
else {
  highest = value3;
 }
}[ATTACH type="full"]1600800[/ATTACH]
else{
 if (value2 >= value3){
  highest = value2;
else {
  highest = value3;
 }
}
 

Attachments

Miwa_

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace test {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {

        }

        int ToInt(string value) {
            return Convert.ToInt32(value);
        }
        private void button1_Click(object sender, EventArgs e) {
            var inputs = new[] { textBox1, textBox2, textBox3 };
            if (inputs.Any(x => string.IsNullOrEmpty(x.Text))) {
                MessageBox.Show("Value cannot be empty", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
           
            List<int> values = new List<int> {
                ToInt(textBox1.Text),
                ToInt(textBox2.Text),
                ToInt(textBox3.Text)
            };

            textBox4.Text = values.Max().ToString();
            textBox5.Text = values.Min().ToString();

        }
    }
}
 
mahirap talaga yan kasi need mo magets how OOP works and ung event driven nature ng windows, which takes time, pero eventually ma gets mo yan, basta lagi ka lang mag code ng mag code and read books from experts (jon skeet and pinaka expert na kilala ko sa c#) and always challenge yourself, based from experience dahil sa nature ng education sa pilipinas mas okay pang mag self learn.
 
Status
Not open for further replies.
Back
Top