473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C# 2005

hi all, first post so pls dont be hard with me :p
well i have this code and i dont know why it says error pls check it :

double total = 0.0;
int size = _receipt.Count;
for (int i = 0; i <= size; i++)
{
if ((Receipt)_receipt[i] is ItInvoices) //the ERROR is in this line
{
ItInvoices itinvoi = (ItInvoices)_receipt[i];
total = total + itinvoi.getNeto();
}
else
{
Ticket tick = (Ticket)_receipt[i];
total = total + tick.getNeto();
}
Console.WriteLine(total);
}


the ERROR says: The index was outside the interval. It must be a nonnegative and inferior value to the size of the collection. Name of the parameter: index
May 3 '07 #1
2 987
prabunewindia
199 100+
hi friend,
see the for loop
the interval--> i=0;i<=size
plz delete the = and try
i=0;i<size
Prabu
hi all, first post so pls dont be hard with me :p
well i have this code and i dont know why it says error pls check it :

double total = 0.0;
int size = _receipt.Count;
for (int i = 0; i <= size; i++)
{
if ((Receipt)_receipt[i] is ItInvoices) //the ERROR is in this line
{
ItInvoices itinvoi = (ItInvoices)_receipt[i];
total = total + itinvoi.getNeto();
}
else
{
Ticket tick = (Ticket)_receipt[i];
total = total + tick.getNeto();
}
Console.WriteLine(total);
}


the ERROR says: The index was outside the interval. It must be a nonnegative and inferior value to the size of the collection. Name of the parameter: index
May 3 '07 #2
ty, ty, ty, :p i always have this problem in java also :P
i dont know why i always forgot it jeje
another doubt how can i show a dialog with some text so i can change this line,


Console.WriteLine(total);



ty for answer me
bye
May 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.