βœ… ToString of a list of an object

I'm supposed to return a string of the teacher's name and all the students but we've never used a string like that nor have we made a list of an object and I've been stuck on this for 2 days and it frustrates me so much please help me
No description
No description
No description
No description
27 Replies
Kouhai
Kouhaiβ€’10mo ago
What are you stuck on? Are you stuck on how to format the string?
𝓭𝓾𝓼𝓴𝔂 🐸
idek idk what I'm doing
Kouhai
Kouhaiβ€’10mo ago
What output do you want to get?
𝓭𝓾𝓼𝓴𝔂 🐸
I want to return a string that looks like the third pic(with the students' info)
Kouhai
Kouhaiβ€’10mo ago
Alright, and I assume the 4th pic is what you tried, correct?
Angius
Angiusβ€’10mo ago
No description
Angius
Angiusβ€’10mo ago
Did you mean s = s + ...?
𝓭𝓾𝓼𝓴𝔂 🐸
ebfuowhgou reyes yes
Kouhai
Kouhaiβ€’10mo ago
Or simply s +=
𝓭𝓾𝓼𝓴𝔂 🐸
right but even with that it doesn't work like how do I even add things to a string we never did it
Angius
Angiusβ€’10mo ago
Maybe because curr will never be null You never set it to null
𝓭𝓾𝓼𝓴𝔂 🐸
but it will get to null when it goes over all the students
Angius
Angiusβ€’10mo ago
Why would it?
𝓭𝓾𝓼𝓴𝔂 🐸
because of curr = curr.getnext it will get to the end eventually
Angius
Angiusβ€’10mo ago
What does GetNext() do?
𝓭𝓾𝓼𝓴𝔂 🐸
go to the pointer of it does that make sense? we were told it's just a list
Angius
Angiusβ€’10mo ago
Well, a linked list from what I see But sure So GetNext() returns null when there are no more elements?
Angius
Angiusβ€’10mo ago
In that case, all I can say is debug this code Place a breakpoint, see what happens
Kouhai
Kouhaiβ€’10mo ago
Does GetValue return the student instance in that node?
𝓭𝓾𝓼𝓴𝔂 🐸
yes and student has a ToString so it should work I think
Kouhai
Kouhaiβ€’10mo ago
Yeah it should, do as zzzzzz said, debug the code.
𝓭𝓾𝓼𝓴𝔂 🐸
how do I do that
Kouhai
Kouhaiβ€’10mo ago
Place a breakpoint and launch in debug mode Then step through the code
Angius
Angiusβ€’10mo ago
$debug
MODiX
MODiXβ€’10mo 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.
Want results from more Discord servers?
Add your server