#️⃣ C# Help, hirap ng online class

Status
Not open for further replies.

PHC_Shion

Forum Veteran
Paano po ito lalagyan ng return value?
 

Attachments

  • IMG_20210902_173719.webp
    IMG_20210902_173719.webp
    382.5 KB · Views: 21
Panong return value ts, ano ginagawa mo diyan sa VS Studio? Calculator ba yan? Give us some context para matulungan ka namin.
 
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;
 }
}
 
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

  • USER_SCOPED_TEMP_DATA_photo1630591818767_6839197787823899808.webp
    USER_SCOPED_TEMP_DATA_photo1630591818767_6839197787823899808.webp
    155.1 KB · Views: 13
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.

About this Thread

  • 21
    Replies
  • 940
    Views
  • 8
    Participants
Last reply from:
Baka-Joker-Ito

Trending Topics

Online now

Members online
1,038
Guests online
938
Total visitors
1,976

Forum statistics

Threads
2,274,901
Posts
28,959,245
Members
1,233,482
Latest member
MyNameIsElga
Back
Top