在Visual Studio的Watch窗口中使用LINQ表达式(Using LINQ expressions in Visual Studio's Watch window)
我在程序中有一个byte []变量,例如:
byte[] myByteArray = new byte[] { 0xF0, 0x0F };
调试此程序时,我想在Visual Studio的Watch窗口中将字节数组内容显示为单独的十六进制值。
所以我尝试在Watch Window中使用以下LINQ表达式,但没有成功:
myByteArray.Select(value => value.ToString("X2")).ToArray()
观察窗口的错误消息:
错误CS1061:'byte []'不包含'Select'的定义,并且没有扩展方法'Select'接受类型'byte []'的第一个参数可以找到(你是否缺少using指令或汇编引用? )
有没有人知道是否有办法在Visual Studio的Watch窗口中使用LINQ表达式而不安装第三方扩展?
我现在正在使用VS2017 15.6.6。
编辑:此问题的屏幕截图...
I have a byte[] variable in program, e.g.:
byte[] myByteArray = new byte[] { 0xF0, 0x0F };
When debugging this program, I wanted to display the byte array content as individual hexadecimal values inside Visual Studio's Watch window.
So I tried to use the following LINQ expression in the Watch Window, without success:
myByteArray.Select(value => value.ToString("X2")).ToArray()
Watch window's error message:
error CS1061: 'byte[]' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'byte[]' could be found (are you missing a using directive or an assembly reference?)
Does anyone know if there is a way to use LINQ expressions in Visual Studio's Watch window without installing third-party extensions?
I'm using VS2017 15.6.6 at this moment.
Edit: A screenshot of this issue...
原文:https://stackoverflow.com/questions/49996480
最满意答案
您应该用eval替换
assignin
,因为assignin
在调用函数调用returns_ext
或基础工作区时分配。 请参阅下面的简单示例:function test newData1.prices = 1; newData1.dates = 2; variables = {'prices','dates'}; for i = 1:length(variables) temp = newData1.(variables{i}); eval([variables{i} ' = temp;']); end disp(prices) disp(dates)
You should replace
assignin
by eval, sinceassignin
assigns either in the caller function callingreturns_ext
or the base workspace. See the simple example below:function test newData1.prices = 1; newData1.dates = 2; variables = {'prices','dates'}; for i = 1:length(variables) temp = newData1.(variables{i}); eval([variables{i} ' = temp;']); end disp(prices) disp(dates)
相关问答
更多-
d3.csv仅用于在加载数据时填充数据,因此它提供了一个回调函数来处理这个问题。 但在你的情况下,你根本不需要那个回调。 你只需要调用d3.append函数并引入你的数据,如下所示: someSVG.selectAll(".element-class") .data(your_data_variable) .enter() .append("circle") .classed("range-circle-inner", true) .attr({ // h ...
-
尝试使用 files <- file.info(list.files(path = t,pattern = "", full.names=TRUE)) files <- subset(files, !isdir & size > 0) temp <- lapply(rownames(files), fread, sep=',') 因为list.files也显示目录。 您在files创建的data.frame可以轻松地位于isdir列上,用于指示这是一个目录还是一个文件。 try using files < ...
-
您应该用eval替换assignin ,因为assignin在调用函数调用returns_ext或基础工作区时分配。 请参阅下面的简单示例: function test newData1.prices = 1; newData1.dates = 2; variables = {'prices','dates'}; for i = 1:length(variables) temp = newData1.(variables{i}); eval([variables{i} ' = temp; ...
-
在某些时候, fread()返回[]空。 我可以演示如何重现错误: a = zeros(2,2) a = 0 0 0 0 a(2,1:2) = [] Subscripted assignment dimension mismatch. 我建议使用textscan()而不是fread() 。 At some point fread() returns [] empty. I can show how to reproduce the error: a = zeros( ...
-
如果要将字符串和数字写入Excel,则需要编写单元数组。 重要的是,单元格数组的每个元素都会写入单个Excel单元格。 在您的情况下,您将尝试将向量写入第二个单元格,这将无法正常工作。 这是你想要做的: sample = [1;2;3;4] %# transform sample to a cell array %# with one number per element sample = num2cell(sample); %# create header header = {'Title'}; ...
-
您是否已设置iOS应用程序以从手表应用程序处理healthkit授权? 当您请求从Apple Watch使用healthkit类型的权限时,您的iOS应用程序上会显示权限对话框。 但是,您需要告诉您的iOS应用,您希望Apple手表能够请求它。 您可以使用AppDelegate文件中的以下代码执行此操作: func applicationShouldRequestHealthAuthorization(application: UIApplication) { let healthStore = H ...
-
这不会像你尝试的那样工作。 您的函数在执行page.DocumentCompleted-delegate之前返回。 因此,您唯一能做的就是将回调传递给在您的委托中执行的GetNews函数。 同步< - >异步的旧问题。 此外,您应该交换语句.Navigate和.DocumentCompleted + =以确保“page”在开始加载任何内容之前设置了回调。 [编辑]为此,您需要创建一个委托并更改您的功能: public delegate void NewsCallback( string dataReceiv ...
-
示例数据编译错误(Sample Data Compilation Error)[2023-09-24]
我后来发现的更好的解决方案允许您将示例数据文件保留为项目的一部分,但删除了编译错误。 要实现这一点,只需右键单击示例数据文件(它将具有.xaml扩展名)。 从弹出菜单中选择属性(通常是列表中的最后一个条目)。 在属性面板中,查找“构建操作”条目。 它很可能设置为Page或其他一些值,导致样本数据xaml与您的应用程序一起编译。 通过从下拉列表中选择“无”条目,将“构建操作”的值更改为“无”。 保存,编译,您将不再收到有关只读属性的编译错误消息。 A better solution I found later ... -
由于块由至少两个新行分隔,您可以使用它将文本分成块并单独分析它们。 试试这个代码 fileH = fopen('fn1_2.out'); content = fscanf(fileH, '%c', inf); fclose(fileH); splitstring = regexp(content, '\r\n\r\n', 'split'); blocks = regexp(splitstring, '\d\.\d{4}.*\r\n.*\d\.\d{4}','match'); numericBlocksI ...
-
将它传递给时间,而不是字符串。 (不幸的是,这会引入一些额外的函数调用开销,所以只有当时间淹没那个开销时它才有用。) time = timeit.timeit(lambda: module.expensive_func(data)) Pass it a callable to time, rather than a string. (Unfortunately, this introduces some extra function call overhead, so it's only viable w ...