【问题标题】:Code Generation for interface....Quick Actions and Refactorings feature in Visual Studio 2015界面代码生成......Visual Studio 2015 中的快速操作和重构功能
【发布时间】:2019-04-27 16:11:32
【问题描述】:

Click here for demo of problem 这发生在 Visual Studio Community 2015 版本 14.0.25431.01 更新 3 关于框架 4.7

这本书是这么说的(John Sharp,Microsoft Visual Studio,Step by Step,八版,第 427 页。)

“返回TreeEnumerator类的定义。在类声明中,将鼠标悬停在文本IEnumerator上。在出现的下拉上下文菜单上(带有灯泡图标)--(我假设他的意思是在你正确之后-单击)--单击“显式实现接口”。

当我右键单击时,我没有看到“显式实现接口”,但我看到了“快速操作重构”,并且因为另一个链接(我正在尝试找到)说这是正确的选项,所以我选择了它,但实际上什么也没发生……好像我什么都没做……

using System;



public class TreeEnumorator<TItem> : IEnumerator<TItem> where TItem : IComparable<TItem>
{
    private TreeEnumorator<TItem> currentData = null;
    private TItem currentItem = default(TItem);
    private Queue<TItem> enumData = null;

    //***** when dealing with a generic class, the constructor does not have <TYPE>
    //NOTICE the name of the constructor is not TreeEnumorator<TItem>
    public TreeEnumorator(Tree<TItem> data)
    {
        this.currentData = data;
    }

    private void populate(Queue<TItem> enumQueue, Tree<TItem> tree)
    {
        if (tree.LeftTree != null)
        {
            populate(enumQueue, tree.LeftTree);
        }

        enumQueue.Enqueu(tree.NodeData);

        if (tree.RightTree != null)
        {
            populate(enumQueue, tree.RightTree);
        }

    }

【问题讨论】:

  • 这对我来说很好用。至少,我们需要知道 VS2015 的确切版本(例如 Update 1 等)才能提供建议。
  • 我不是从链接中得到的。我从 Jhon Sharp 的《Microsoft C# Step by Step 第八版》一书中得到它。第 427 页。我可以将其粘贴到问题中。给我一分钟。请投票支持。我会解决这个问题....
  • This website is quick to close your account, 这根本不是真的。我不知道你为什么这么想。
  • 请使用 LiceCap 或类似工具向我们展示您右键单击并选择 Quick Actions Refactorings 的动画 gif,并将 gif 附加到您的问题中。
  • 将文件顶部改为using System; using System.Collections.Generic;

标签: c# visual-studio visual-studio-2015


【解决方案1】:

我创建的代码放在我的解决方案项目文件夹中。 它没有放在我的项目文件夹中。 一旦我移动它,它就可以正常工作了......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多