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 881679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:18:05+00:00 2026-05-15T12:18:05+00:00

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data;

  • 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
namespace shop_management
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public class user
        {
            public string İsim { set; get; }
            public string Borç { set; get; }

        }
        public class item
        {
            public string Tehlike { set; get; }
            public string İsim { set; get; }
            public decimal Birim { set; get; }
            public decimal Miktar { set; get; }

        }
        public MainWindow()
        {
            this.InitializeComponent();
            if (!(File.Exists("C:\\data\\users"))) //here the software checks if the files exist or not
            {
                MessageBox.Show("Error!!!");
                this.Hide();
            }
            if (!(File.Exists("C:\\data\\items")))
            {
                MessageBox.Show("Error!!!");
                this.Hide();
            }
            string dan_in="";
            StreamReader sr_main;
            int i = 0,j=0;
            List<item> list_items = new List<item>();
            string first_read;
            sr_main = File.OpenText("C:\\data\\items"); //this is the file that we take our items data
            first_read = sr_main.ReadToEnd();
            string[] manip_read = first_read.Split('\t'); //in the file, there is only "/t"s between datas. for example "name1/tprice1/tcount1/tdanger1t/name2/tprice2/tcount2/tdanger2" etc.
            item[] items = new item[300]; //here i declared a 300 items long array, which means the software will crash if there is 301, solve this!
            foreach (string line in manip_read)
            {


                if (i == 0) items[j].İsim = line; //this line keeps record of the items name
                if (i == 1) items[j].Birim = Convert.ToDecimal(line); // this line keeps the price
                if (i == 2) items[j].Miktar = Convert.ToDecimal(line); // this line keeps how many left
                if (i == 3) items[j].Tehlike = line; //and this line keeps the danger level
                i++;
                if (i == 4) //here the loop adds the data to list
                {
                    if (items[j].Miktar < Convert.ToDecimal(items[j].Tehlike) || items[j].Miktar == Convert.ToDecimal(items[j].Tehlike)) dan_in = "!!!";
                    list_items.Add(new item() { İsim = items[j].İsim, Miktar =items[j].Miktar , Birim=items[j].Birim, Tehlike=dan_in });
                    dan_in = "";
                    i = 0;
                    j++;
                }

            }
            grid_items.ItemsSource = list_items;
        }
    }
}

Here the problem is, i ran this part of the software before, but without the items[300] array. At that time, there is only one instance of item, but now i also need to keep them in a array. It seems there is an error with the first if statement that tries to assign the name İsim value of the first item (item[0]).

thanks for any help

  • 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-15T12:18:06+00:00Added an answer on May 15, 2026 at 12:18 pm

    You’re not assigning a value to the element itself – somewhere you need:

    items[j] = new item();
    

    Currently you’re just trying to set properties on an object that doesn’t exist – i.e. via a null reference.

    (I would agree with the idea of using a List<item> as well, by the way. I’d also rename item to Item to fit in with .NET naming conventions.)

    Given your current code, the simplest solution is probably this:

    if (i == 0)
    {
        items[j] = new item();
        items[j].İsim = line;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 496k
  • Answers 496k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here are few things to follow: You should package your… May 16, 2026 at 11:49 am
  • Editorial Team
    Editorial Team added an answer Actually no. However... Some databound controls, such as the ListView,… May 16, 2026 at 11:49 am
  • Editorial Team
    Editorial Team added an answer Have a look at this post http://groups.google.com/group/android-discuss/browse_thread/thread/7ab083cabe70e77c?pli=1 May 16, 2026 at 11:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This C#/WPF code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using
This is my problem: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1
hi this is my multi thread codes it works fine using System; using System.Collections.Generic;
I try to add a record to SQLServer db table using LINQ to SQL
I have a situation where I am using wpf data binding and validation using
I'm trying to use the Windows 7 Taskbar API to set the overlay icon
I'm trying to do some simple data retrieval with C# and Directory Services, but
While designing a new WPF application I noticed exceptions not being thrown during data
Using WPF .NET 4.0 in VS2010 RTM: I can't create a fullscreen WPF popup.
I decided to try out LINQ for the first time to try and solve

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.