I'm VERY new to C#

I need help with a certain Lab Program of mine and I barely know anything in C#. Anyone willing to help please join the VC I am in so that I can show my code and my problem.
16 Replies
Angius
Angius13mo ago
Or you can post the code and describe your problem here
thelonelyghost
thelonelyghostOP13mo ago
uhhh okay one min That right there is my code My problem is with the checking for repeated schedule part Everytime I try to put an invalid schedule timing deliberately (as in, within another meeting hours) it throws ArgumentOutOfRangeException
Angius
Angius13mo ago
That means you're trying to access an array element that does not exist
thelonelyghost
thelonelyghostOP13mo ago
I don't know why that is happening or how to catch that and lead it to display that message box
Angius
Angius13mo ago
If item.SubItems has less than three elements, it won't have anything at index 2 You have to remember that arrays in C# are 0-indexed, too
thelonelyghost
thelonelyghostOP13mo ago
But I have already scheduled a meeting of the same timing and it is also displayed in the listView...
Angius
Angius13mo ago
element ["a", "b", "c"]
index 0 1 2
element ["a", "b", "c"]
index 0 1 2
thelonelyghost
thelonelyghostOP13mo ago
yeah...I understood that part..
Angius
Angius13mo ago
So either that is the issue, or item.SubItems does not have as many elements as you think it does You can always use the debugger to see what it's actual value is $debug
MODiX
MODiX13mo ago
Tutorial: Debug C# code and inspect data - Visual Studio (Windows)
Learn features of the Visual Studio debugger and how to start the debugger, step through code, and inspect data in a C# application.
thelonelyghost
thelonelyghostOP13mo ago
Thank you I kinda, didn't understand what I have to do about that though.. Sorry
Angius
Angius13mo ago
1. Place a breakpoint before you call the code that causes the error 2. Run the debugger 3. When the execution hits the breakpoint, check the values of your variables See if item.SubItems actually contains what you think it contains
thelonelyghost
thelonelyghostOP13mo ago
Thank you so much for the help. I just realised how I messed up. It didn't XD
Angius
Angius13mo ago
There you have it
thelonelyghost
thelonelyghostOP13mo ago
Thank you so much!!
Angius
Angius13mo ago
Anytime Ok

Did you find this page helpful?