C
C#2y 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
Ezlanding2y ago
C# has one already. Just use that
yatta
yatta2y ago
ye I know about it, but I want to practice manually, so is there anyway ?
Ezlanding
Ezlanding2y ago
What’s the error it gives?
yatta
yatta2y ago
something like this
yatta
yatta2y ago
i changed something so now only one error
Ezlanding
Ezlanding2y ago
It can’t iterate the class
yatta
yatta2y ago
is it because the reference value have to be null ?
Ezlanding
Ezlanding2y 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
Ezlanding2y ago
A for loop would be easier @yatta
yatta
yatta2y ago
I'll try with it
Ezlanding
Ezlanding2y 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);
}