标签: visual-studio-2015

允许用户键入"-999"以退出控制台应用程序

在C#的新手中,我想知道如何允许用户输入-999来退出应用程序.我正在使用视觉工作室2015,我正在研究控制台应用程序,我认为这样的东西会起作用

        string userInput;
        userInput = Console.ReadLine();

        if (userInput == "-999")
        {
            Application.Exit();
        }
Run Code Online (Sandbox Code Playgroud)

但我错了,有没有办法做类似的事情呢?谢谢.

c# console-application visual-studio-2015

0
推荐指数
1
解决办法
105
查看次数

VS 2015 RC中无法使用Windows应用商店应用

我正在尝试为Windows 8创建我的第一个Store应用程序.

我安装了VS2015 RC和适用于Windows 8 的Windows软件开发套件(我按照本页的说明操作).不幸的是,我无法在VS中看到Windows Apps模板,这与链接显示的不同存储应用模板.

我在Windows 7机器上运行VS2015 Enterprise RC.

我错过了什么?谢谢

c# windows-8 windows-store-apps visual-studio-2015

-1
推荐指数
1
解决办法
1298
查看次数

"A使用B,正在定义"是什么意思?

现在我按照规则要求做了,并且首先看看是否已经回答了这个问题,虽然我确实找到了一个帖子,但它未能解决我的具体问题,因此我自己问.

对于一个简短的上下文,这个错误在我正在制作的双链表列表的节点类中,因此很明显节点必须对其进程和前面的邻居有一些了解

以下代码......

    template<class T> class dslListNode
    {
    public:
        dslListNode(T data, dslListNode<T>* next, dslListNode<T>* prev)
        : m_data(data)
        {
            this->m_next = next;
            this->m_prev = prev;
        }

        T m_data;
        dslListNode<T>* m_next, m_prev;   //<-- line twelve
        void purge()
        {
            if (this->m_next != NULL)
            {
                this->m_next->purge();
                delete this->m_next;
            }
        }
    private:
    };
Run Code Online (Sandbox Code Playgroud)

...在第十二行不会停止给我以下错误

Error   C2460
'dslListNode<T>::m_prev': uses 'dslListNode<T>', which is being defined
Run Code Online (Sandbox Code Playgroud)

所以你...

我老实说不知道现在发生了什么,我在c ++的技能还没达到我理解为什么会发生这种事情的程度,到目前为止互联网没有帮助这方面,因此我请求帮忙.

为什么会发生这种情况,我该怎么做才能解决它?

为我的语法和拼写道歉btw = D.

谢谢先进=)

c++ visual-studio visual-c++ visual-studio-2015

-1
推荐指数
1
解决办法
755
查看次数

没有实现的接口没有编译错误

在最小的奇怪,但我相信存在一个解释...我有一个接口(IRepository)有6个方法由类实现.但是当我把代码用于实现接口时,VS2015并没有向我显示实现类的选项,如果我没有手动实现并编译项目它不会显示编译错误,不应该吗?如果它出现编译错误告诉我,我没有实现接口.

接口:

 public interface IRepository<T> where T : class
{       
    IQueryable<T> GetAll ();
    IQueryable<T> FindBy ( Expression<Func<T, bool>> predicate );
    void Add ( T entity );
    void Delete ( T entity );
    void Edit ( T entity );
    void Save ();
}
Run Code Online (Sandbox Code Playgroud)

应该实现IRepository但不实现的类,它不会抛出编译错误:

public class GenericRepository<T> where T : class, IRepository<T>
{
}
Run Code Online (Sandbox Code Playgroud)

c# interface visual-studio-2015

-1
推荐指数
1
解决办法
62
查看次数

错误C2039:'chrono':不是'std'的成员

我正在使用Visual Studio 2015来创建Win32项目.我试图使用chrono库,但它说它无法找到它.我在控制台项目中使用chrono库测试了代码,但是它在控制台项目上工作,但在Win32项目上没有.

#include <chrono>
...
using namespace std::chrono;

LocalDriveHeader header;
auto durnow = system_clock::now ().time_since_epoch ();

header.version = VERSION;
header.flags = 0x0000;
header.sector_size = sector_size;
header.early_time = chrono::duration_cast <milliseconds> (durnow).count ();
...
Run Code Online (Sandbox Code Playgroud)

===编辑===

是的,我确实包括了chrono标题.该项目是带有预编译头的Win32项目.

c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(123): error C2039: 'chrono': is not a member of 'std'
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\memory(1175): note: see declaration of 'std'
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(123): error C2871: 'chrono': a namespace with this name does not exist
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(126): error C2653: 'system_clock': is …
Run Code Online (Sandbox Code Playgroud)

c++ c++-chrono visual-studio-2015

-1
推荐指数
2
解决办法
2968
查看次数

使用Visual Studio在c#中使用Convert.ToString()替换().ToString()

我希望看看是否有一种简单的方法可以使用Code Resharper或CodeRush或任何其他工具在整个应用程序中使用Convert.ToString()替换().ToString()?

谢谢

c# resharper visual-studio visual-studio-2015

-1
推荐指数
1
解决办法
547
查看次数

为什么`警告C4804:'>':在操作中不安全地使用类型'bool'在Visual Studio 2015上弹出?

为什么warning C4804: '>': unsafe use of type 'bool' in operation在Visual Studio 2015上弹出?

如果您运行此代码:

#include <iostream>
#include <cstdlib>

int main( int argumentsCount, char* argumentsStringList[] )
{
#define COMPUTE_DEBUGGING_LEVEL_DEBUG      0
#define COMPUTE_DEBUGGING_DEBUG_INPUT_SIZE 32

    int inputLevelSize;
    int builtInLevelSize;

    inputLevelSize   = strlen( "a1" );
    builtInLevelSize = strlen( "a1 a2" );

    if( ( 2 > inputLevelSize > COMPUTE_DEBUGGING_DEBUG_INPUT_SIZE )
        || ( 2 > builtInLevelSize > COMPUTE_DEBUGGING_DEBUG_INPUT_SIZE ) )
    {
        std::cout << "ERROR while processing the DEBUG LEVEL: " << "a1" << std::endl;
        exit( …
Run Code Online (Sandbox Code Playgroud)

c++ cl visual-studio-2015

-1
推荐指数
1
解决办法
3788
查看次数

Visual Studio不遵循移动语义

我在Visual Studio 2015 v4中尝试此代码.

using namespace std;

void * operator new(size_t size) {
    cout << "Creating new " << endl;
    void * p = malloc(size);
    return p;
}


class CTest {
private:
    string a;
    string b;
public:
    CTest( const string &&one , const string && two  ) :a(move(one)), b(move(two)) {}
};


int main() {
    CTest("one", "one" );
    return 0;   
}
Run Code Online (Sandbox Code Playgroud)

此代码在Visual Studio中输出"Creating new"4次,这意味着它分配内存4次.但是遵循语义它应该只分配两次(在数据段中创建2个文字,创建一个和两个函数参数= 2个alloc,然后将它们的资源移动到a和b成员变量)

在g ++下编译它会两次输出"Creating new",就像它应该的那样.

我需要设置任何设置才能使VS遵循移动语义吗?据我所知,它应默认支持.

感谢帮助.

c++ visual-studio move-semantics c++11 visual-studio-2015

-1
推荐指数
1
解决办法
60
查看次数

IEnumerable 和 OrderBy 的奇怪之处

我有一段看起来很简单的代码,但似乎并非如此。

// Enum values
IEnumerable values = Enum.GetValues(typeof(TVal)).Cast<TVal>();

// Sort them by alpha
if (sortByAlpha)
{
    values = (values).OrderBy(i => i.ToString());
}
Run Code Online (Sandbox Code Playgroud)

如果我写:

// Get enum values
IEnumerable values = Enum.GetValues(typeof(TVal)).Cast<TVal>();

// Sort them by alpha
if (sortByAlpha)
{
    values = Enum.GetValues(typeof(TVal)).Cast<TVal>().OrderBy(i => i.ToString());
}
Run Code Online (Sandbox Code Playgroud)

有用。

为什么?第一段代码中的值应该相同吗?我没有看到什么?在 .Net 4.5.1 上运行

.net c# linq ienumerable visual-studio-2015

-1
推荐指数
1
解决办法
68
查看次数

数字和特殊字符不起作用

我试图取代a4在RichTextBox.它将文本"a"替换为"4"而不是"4nsi4nsicpg1252ng16393rd4r".

这是我正在使用的代码: RichTextBox1.Rtf = RichTextBox1.Rtf.Replace("a", "4")

有关如何用"4"替换"a"的任何帮助?顺便说一句,我可以用"测试"而不是"4"代替"a"

vb.net visual-studio-2015

-2
推荐指数
1
解决办法
50
查看次数