Problem z typem bool. - wyświetlanie "Aktywny" zamiast "True"

0

Witam,

mam pewien problem dot. tak jak w tytule typu bool. Otóż napisałem program, który ma za zadanie wyświetlanie informacji odnośnie konkretnych osób należących do danej grupy. Chciałem, aby w listBoxie zamiast "True", "False" wyświetlała się informacja w postaci tekstu "Aktywny"(True), "Nieaktywny"(False). Moje pytanie brzmi - jak tego dokonać ?

Z góry uprzejmie dziękuję.


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 Studenci_grupy
{
    public partial class Form1 : Form
    {
        List<Studenci> listaStudentow = new List<Studenci>();
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            Studenci st1 = new Studenci();
            st1.Imie = "Janusz";
            st1.Nrgr = 1;
            st1.Rok = 1997;
            st1.Rej = true;
 
            Studenci st2 = new Studenci();
            st2.Imie = "Homobonus";
            st2.Nrgr = 2;
            st2.Rok = 1998;
            st2.Rej = false;
 
            Studenci st3 = new Studenci();
            st3.Imie = "Grażyna";
            st3.Nrgr = 1;
            st3.Rok = 1999;
            st3.Rej = true;
 
            Studenci st4 = new Studenci();
            st4.Imie = "Halina";
            st4.Nrgr = 1;
            st4.Rok = 1960;
            st4.Rej = false;
 
            Studenci st5 = new Studenci();
            st5.Imie = "Sebastian";
            st5.Nrgr = 2;
            st5.Rok = 1998;
            st5.Rej = true;
 
            listaStudentow.Add(st1);
            listaStudentow.Add(st2);
            listaStudentow.Add(st3);
            listaStudentow.Add(st4);
            listaStudentow.Add(st5);
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {  
            if(comboBox1.SelectedIndex==-1)
            {
                MessageBox.Show("Proszę wybrać grupę z pola wyboru");
            } 
 
            Studenci grupy = new Studenci();
            grupy.Nrgr = int.MinValue;
 
            int grupa = comboBox1.SelectedIndex; 
             
            foreach (Studenci stn in listaStudentow)
            {              
                if (grupa == 0) 
                {
                    listBox1.Items.Remove(stn.Imie + "  " + stn.Rok + "  " + stn.Rej);
                }
 
                if (grupa == 0)
                {
                    if (stn.Nrgr == 1) 
 
                    listBox1.Items.Add(stn.Imie + "  " + stn.Rok + "  " + stn.Rej);
                }
 
                if (grupa == 1) 
                {
                    listBox1.Items.Remove(stn.Imie + "  " + stn.Rok + "  " + stn.Rej);
                }
 
                if (grupa == 1) 
                {
                    if (stn.Nrgr == 2)
 
                    listBox1.Items.Add(stn.Imie + "  " + stn.Rok + "  " + stn.Rej);
                }
            }
        } 
 
        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}


3
var item = $"{stn.Imie} {stn.Rok} {(stn.Rej ? "Aktywny (true)" : "Nieaktywny (false)")}";

1 użytkowników online, w tym zalogowanych: 0, gości: 1