Following code results with error:
Cannot implicitly convert type 'void' to 'char'
string S = "Hello World!";
LinkedList<char> myChars = new LinkedList<char>();
foreach (char ch in S)
{
myChars.AddFirst(ch);
}
char c = myChars.RemoveFirst();
How can I remove first element and copy it to a char variable c?
Thank you!
You can do it like this:
var node = myChars.First;
char c = node.Value;
myChars.Remove(node);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.