Current filter:
                                You should refresh the page.
                                0
                                  • Consider the following code:

                                    public class Node
                                    {
                                        public string Name { get; private set; }
                                        public Node Parent { get; private set; }
                                    }

                                    public class RootNode : Node
                                    {
                                    }

                                    public class Tree
                                    {
                                        private RootNode root;

                                        private Node FindNode(string name)
                                        {
                                            Node node = root;
                                            while (node != null)
                                            {
                                                if (node.Name == name)
                                                {
                                                    return node;
                                                }

                                                node = node.Parent;
                                            }

                                            return null;
                                        }
                                    }

                                    The 'Implicit variable can be used' code issue reports that the variable 'node' in FindNode() can be made implicit. However, applying Make Implicit here causes a compiler error because it results in the subclass 'RootNode' being used. This is a problem because node.Parent returns the superclass 'Node'.

                                You must  log in  or  register  to leave an answer

                                Is your intention to post an answer to your own question?

                                • If so, then proceed.
                                • If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
                                • If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.