虽然我确实理解了泛型的一些角落情况,但我遗漏了以下示例的内容.
我有以下课程
1 public class Test<T> {
2 public static void main(String[] args) {
3 Test<? extends Number> t = new Test<BigDecimal>();
4 List<Test<? extends Number>> l =Collections.singletonList(t);
5 }
6 }
Run Code Online (Sandbox Code Playgroud)
第4行给出了错误
Type mismatch: cannot convert from List<Test<capture#1-of ? extends Number>>
to List<Test<? extends Number>>`.
Run Code Online (Sandbox Code Playgroud)
显然,编译器认为不同的不同?.虽然我的直觉告诉我,这是正确的.
任何人都可以提供一个例子,如果第4行合法,我会得到运行时错误吗?
编辑:
为了避免混淆,我用第=null3行替换了具体的赋值
有没有办法使用.NET技术记录屏幕,无论是桌面还是窗口.
我的目标是免费的.我喜欢小巧,低CPU使用的想法,而且简单,但如果他们创造了更好的最终产品,我会考虑其他选择.
简而言之,我知道如何在C#中截取屏幕截图,但我如何将屏幕或屏幕区域记录为视频?
非常感谢您的想法和时间!
我有个问题.目前,WebView 的capturePicture已弃用.
我想问一下是否有办法替换这个功能.我的意思是它可以捕获整个webview(不仅显示视图)
谢谢
我正在和一个工作人员一起工作TreeTable时,我需要通过一个
Callback<TreeTableColumn<A, capture of ?>, TreeTableCell<A, capture of ?>>
Run Code Online (Sandbox Code Playgroud)
A是我正在使用的课程,但我不知道如何处理"捕获?"
我试图创造
new Callback<TreeTableColumn<A, ?>, TreeTableCell<A, ?>>
Run Code Online (Sandbox Code Playgroud)
但IDEA显示出警告
setCellFactory(Callback<TreeTableColumn<A, capture<?>>, TreeTableCell<A, capture<?>>>) in TreeTableColumn cannot be applied to (anonymous Callback<TreeTableColumn<A, ?>, TreeTableCell<A, ?>>)
Run Code Online (Sandbox Code Playgroud)
我尝试使用特定的类(如String)而不是"?" 同样,但没有任何帮助.
谁能向我解释如何使用它?
谢谢.
编辑:
我聚集了一点点信息.该CellFactory的TreeTableColumn<S,T>应该是Callback<TreeTableColumn<S,T>,TreeTableCell<S,T>>但是,我与原始类型创建工作(在库)的TreeTableColumn.
使用原始类型回调有效.但有没有其他选择如何解决这个问题?
我正在使用C#和Visual Studio 2010.
当我OutputDebugString用来编写调试信息时,它应该出现在输出窗口中吗?
我可以OutputDebugString在DebugView中看到输出,但我想我会在Visual Studio的Output窗口中看到它.我看过菜单工具?选项?调试?常规,输出未被重定向到立即窗口.我也看了菜单工具*?选项?调试?输出窗口和所有常规输出设置都设置为"开".最后,我使用了Output窗口中的下拉列表来指定应该出现Debug消息.
如果我更改菜单工具*?选项?调试?一般将输出重定向到立即窗口,OutputDebugString消息不会出现在即时窗口中.
这是我的整个测试程序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace OutputDebugString
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern void OutputDebugString(string message);
static void Main(string[] args)
{
Console.WriteLine("Main - Enter - Console.WriteLine");
Debug.WriteLine("Main - Enter - Debug.WriteLine");
OutputDebugString("Main …Run Code Online (Sandbox Code Playgroud) 我想添加一个javascript函数来捕获<a>html页面内的所有点击事件.
所以我添加了一个管理所有<a>点击事件的全局函数,但没有添加onclick给每个(既不使用.onclick=也不attachEvent(onclick...)是内联onclick=).我会在html中留下<a>简单的内容,<a href="someurl">而不会触及它们.
我尝试window.onclick = function (e) {...}
但只捕获所有点击如何仅指定点击<a>并提取<a>被点击的内部链接?
限制:我不想使用任何exra库,如jQuery,只是vanilla javascript.
我需要在bash脚本中捕获命令的输出和错误,并知道命令是否成功.
目前,我正在捕捉这两个:
output=$(mycommand 2>&1)
Run Code Online (Sandbox Code Playgroud)
然后我需要检查mycommand的退出值.如果失败了,我需要对输出做一些事情,如果命令成功,我不需要触摸输出.
由于我正在捕获输出,检查$?因为bash成功地将输出捕获到变量中,所以总是为0.
这是一个非常时间敏感的脚本,所以我们试图避免任何较慢的解决方案,如输出到文件并重新读取它.
如果我可以将stdout捕获到一个变量并将stderr捕获到另一个变量,这将解决我的问题,因为我可以检查错误变量是否为空.
谢谢.
摘要:
完整问题:
我需要找到一种在csharp中运行命令行命令并捕获其输出的方法.我知道如何在Perl中执行此操作,下面是我将在Perl中使用的代码.
#machine to check
my $pc = $_[0];
#create location of registry query
my $machine = "\\\\".$pc."\\HKEY_USERS";
#run registry query
my @regQuery= `REG QUERY $machine`;
Run Code Online (Sandbox Code Playgroud)
有关如何在csharp中执行此操作的任何建议都将受到欢迎.到目前为止,我已经尝试使用RegistryKey OurKey = Registry.Users方法,它工作得很好但我无法在远程计算机上查询注册表.
如果您需要更多信息,请与我们联系.
解决方案:(谢谢@Robaticus)
private void reg(string host)
{
string build = "QUERY \\\\" + host + "\\HKEY_USERS";
string parms = @build;
string output = "";
string error = string.Empty;
ProcessStartInfo psi = new ProcessStartInfo("reg.exe", parms);
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
psi.UseShellExecute …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行以下操作:
module ApplicationHelper
class PModuleHelper
include ActionView::Helpers::TagHelper
def heading(head = "", &block)
content = block_given? ? capture(&block) : head.to_s
content_tag :h3, content, :class => :module_header
end
end
def getmh
PModuleHelper.new
end
end
Run Code Online (Sandbox Code Playgroud)
为方法heading或块提供字符串(或符号).
在视图中:
<% mh = getmh %>
<%= mh.heading :bla %> // WORKS
<%= mh.heading do %> // FAILS
test 123
<% end %>
Run Code Online (Sandbox Code Playgroud)
(注意这getmh只是为了这个例子,PModuleHelper我的应用程序中的一些其他进程返回,所以不需要对此进行评论或建议制作heading正常的辅助方法,而不是类方法)
不幸的是我总是收到以下错误:
wrong number of arguments (0 for 1)
Run Code Online (Sandbox Code Playgroud)
与亚麻布的capture(&block)电话.
如何使用capture自己的助手类?
这段代码很容易
Bitmap bitmap;
View v1 = MyView.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
Run Code Online (Sandbox Code Playgroud)
并且效果很好,但如果有活动就是这种情况.
如何从服务中截取屏幕截图?
我的目标是在一小时内截取屏幕截图,ei以每小时关闭屏幕,例如在12中然后在1中然后在2中......依此类推