C
C#3y ago
yatta

How to create a linked list ?

I'm trying co create a linked list manually and print it out as the way I known but it seems things doesn't works as I normal know, can any one help me what should I do in this situation so it can print all the number ?
12 Replies
Ezlanding
Ezlanding3y ago
C# has one already. Just use that
yatta
yattaOP3y ago
ye I know about it, but I want to practice manually, so is there anyway ?
Ezlanding
Ezlanding3y ago
What’s the error it gives?
yatta
yattaOP3y ago
something like this
yatta
yattaOP3y ago
i changed something so now only one error
Ezlanding
Ezlanding3y ago
It can’t iterate the class
yatta
yattaOP3y ago
is it because the reference value have to be null ?
Ezlanding
Ezlanding3y ago
Make a class usable in a foreach statement - C#
Describes how to make a Visual C# class usable in a foreach statement. Also describes a code sample to explain the methods.
Ezlanding
Ezlanding3y ago
A for loop would be easier @yatta
yatta
yattaOP3y ago
I'll try with it
Ezlanding
Ezlanding3y ago
@yatta use this:
ListNode current = nodeList;
for(; current != null; current = current.next){
Console.WriteLine(current.val);
}
ListNode current = nodeList;
for(; current != null; current = current.next){
Console.WriteLine(current.val);
}
Want results from more Discord servers?
Add your server