Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#won';不行。选择?_C#_Visual Studio - Fatal编程技术网

C#won';不行。选择?

C#won';不行。选择?,c#,visual-studio,C#,Visual Studio,我正在构建一个用于显示Smartgraph3读数的程序。无论何时开始调试,命令行都会打开,但随后会立即消失。我知道ctrl+f5可以工作,但我一直在寻找一种解决方案,不必输入相同的命令来防止它消失 我使用了系统(“暂停”);但它在System下不断出现一条蓝线,错误列表中说“System”是一个“名称空间”,但它的用法类似于一个“变量”。有人知道怎么了吗 另外,我听说系统(“暂停”)不应该被使用,所以有没有人有一个同样有效的替代方案 这是我的密码副本。多谢各位 using System;

我正在构建一个用于显示Smartgraph3读数的程序。无论何时开始调试,命令行都会打开,但随后会立即消失。我知道ctrl+f5可以工作,但我一直在寻找一种解决方案,不必输入相同的命令来防止它消失

我使用了系统(“暂停”);但它在System下不断出现一条蓝线,错误列表中说“System”是一个“名称空间”,但它的用法类似于一个“变量”。有人知道怎么了吗

另外,我听说系统(“暂停”)不应该被使用,所以有没有人有一个同样有效的替代方案

这是我的密码副本。多谢各位

    using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Infowerk.SmartGraph3.SmartGraph3API;
//using CSTestClient.SmartGraph;

namespace CSTestClient
{
    class Program
    {
        static void Main(string[] args)
        {
            TestAPI();
        }



        static void TestAPI()
        {
            System.ServiceModel.Channels.Binding service_binding = new BasicHttpBinding();
            EndpointAddress endpoint_address = new EndpointAddress("http://localhost:8000/SmartGraph3API/APIV01");


            SmartGraph3APIClient client = new SmartGraph3APIClient(service_binding, endpoint_address);

            List<SG3APIDeviceIdentification> device_list = client.GetDeviceList();

            foreach (SG3APIDeviceIdentification device_identification in device_list)
            {
                Console.WriteLine("device id: {0}", device_identification.DeviceId);
                System("pause");
            }
        }

    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.ServiceModel;
使用系统文本;
使用Infowerk.SmartGraph3.SmartGraph3API;
//使用CSTestClient.SmartGraph;
命名空间CSTestClient
{
班级计划
{
静态void Main(字符串[]参数)
{
TestAPI();
}
静态void TestAPI()
{
System.ServiceModel.Channels.Binding服务_Binding=new BasicHttpBinding();
EndpointAddress endpoint_address=新的EndpointAddress(“http://localhost:8000/SmartGraph3API/APIV01");
SmartGraph3ApicClient=新的SmartGraph3ApicClient(服务绑定、端点地址);
List device_List=client.GetDeviceList();
foreach(SG3API设备标识设备列表中的设备标识)
{
WriteLine(“设备id:{0}”,设备标识.DeviceId);
系统(“暂停”);
}
}
}
}

继续,简单地使用:

Console.ReadKey();

Main()
的右大括号上设置断点。或者使用一个IDE,将控制台输出流化到一个调试窗口,该窗口在进程退出后保持不变(例如,Eclipse,我假设基本上是VS以外的任何东西)。没有理由强迫所有想要以正常方式运行您的程序的人调用它,如:

:; ./myProgram.exe < /dev/null; exit $?
.\myProgram.exe < NUL
:/myProgram.exe

请参阅。

两件事:(1)不是
System(“pause”)
,而是
System(“pause”)
(小写!),(2)它在C/C++中可用,而您正在使用C,您知道这是一个不同的平台!不只是“他们说它不同,但我的程序仍然有效”,就像它在C和C++中一样。C#与他们完全不同。你应该在这里质疑你的动机。您知道CTRL+F5可以工作,因此您已经有了“正确”的解决方案。为什么还希望它在调试模式下工作?不是人为地在程序中添加一个暂停(这将改变你的最终用户的预期行为),而是使用断点,这是调试会话期间获得这种行为的意图。此外,你的问题非常混乱——你的标题表示C++,你的标签表示C++,你的评论称C++。但您的代码似乎是C,并且您接受了C的答案。你在这地方——什么是真正的语言?编辑C++到标题中什么也不清楚,因为你的代码和接受的答案不是C++。我现在认为这实际上是一个C++/CLI问题(因为我自己对C不太熟悉,一开始我没有发现这一点)。无论哪种方式,它都不是C++,应该适当地加上标记(用C++ -CLI标签)。@ JBentley:不,它不是C++ + CLI,这绝对是简单明了的简单C。我认为这个问题的作者根本没有“感觉到不同”。