Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 196191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:44:47+00:00 2026-05-11T16:44:47+00:00

Hello again; i need to show X,Y,Risk in ListBoxes. But i can not do

  • 0

Hello again; i need to show X,Y,Risk in ListBoxes. But i can not do it.

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<TrainigSet> listtraining = new List<TrainigSet>();
            TrainigSet tr = new TrainigSet();
            double[] X = { 2, 3, 3, 4, 5, 6, 7, 9, 11, 10 };
            double[] Y = { 4, 6, 4, 10, 8, 3, 9, 7, 7, 2 };
            string[] Risk = { "Kötü", "iyi", "iyi", "kötü", "kötü", "iyi", "iyi", "kötü", "kötü", "kötü" };
            for (int i = 0; i < X.Length; i++)
            {
                tr.X = X[i];
                tr.Y = Y[i];
                tr.Risk = Risk[i];
                listtraining.Add(tr);
            }
            for (int i = 0; i < listtraining.Count; i++)
            {
                ListBox1.Items.Add(listtraining[i].X.ToString());
                ListBox2.Items.Add(listtraining[i].Y.ToString());
                ListBox3.Items.Add(listtraining[i].Risk.ToString());
            }
        }
    }
}

public class TrainigSet
{
    public double X { get; set; }
    public double Y { get; set; }
    public string Risk { get; set; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:44:47+00:00Added an answer on May 11, 2026 at 4:44 pm

    You have to move the instantiation/creation of the TrainingSet into the for loop (you want to create a new instance for every item you add to listtraining):

    double[] X = { ... };
    double[] Y = { ... };
    string[] Risk = { ... };
    
    for (int i = 0; i > X.Length; i++)
    {
        TrainigSet tr = new TrainigSet(); // create a new TrainingSet
        ...
        listtraining.Add(tr);
    }
    

    Otherwise you will modify the same TrainingSet instance over and over again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello again, stackoverflow community! I'm working on writing a simple blog system in Rails,
Hello I've runned in to a problem again that I can't solve on my
again me: following array; $myArray = array('FOO', 'BAR', 'HELLO'); i need: $myArray['FOO']['BAR']['HELLO'] = 0;
Hello once again and I need some help. I am developing an automatic updating
Hello and excuse me again I need a REGEX for delete the character space
hello again i finally finish my web service and client and it works fine
Ok really easy I know but not for me... I can not figure this
Hello again codes masters, I'm stuck at this piece of codes for dropdown menu.
Hello again everyone, This time I have a problem with Intent & Extras. here's
hello again, WSO2 community. My last question about your architecture for my research is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.