问题列表 - 第2756页

用户定义的转换到接口

我刚刚遇到C#中的"用户定义的转换到接口或来自接口的转换"问题.我试图做的是创建一个通用的Graph类,可以通过几种不同的方式迭代,具体取决于支持的接口.所以:

public class Graph<T> : IBreadthFirstSearchTree<T>, IDepthFirstSearchTree<T>
{
    // unnecessary details

    public static explicit operator IBreadthFirstSearchTree<T>(Graph<T> g)
    {
        g.enumerator = new GraphEnumerator<T>(g, SortStrategy.BreadthFirst);
        return g as IBreadthFirstSearchTree<T>;
    }

    public static explicit operator IDepthFirstSearchTree<T>(Graph<T> g)
    {
        g.enumerator = new GraphEnumerator<T>(g, SortStrategy.DepthFirst);
        return g as IDepthFirstSearchTree<T>;
    }
}
Run Code Online (Sandbox Code Playgroud)

是用于此用途:

foreach (GraphNode<T> gn in myGraph as IDepthFirstSearchTree)
{
    // do stuff with gn
}
Run Code Online (Sandbox Code Playgroud)

任何人都知道如何在语言的约束下实现相同的语法结果?

c#

3
推荐指数
1
解决办法
3566
查看次数

如何停止 Visual Studio 在(中断所有)暂停按钮上转到 program.cs

这真的很烦人。

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainForm()); <-- pausing visual studio breaks here.
Run Code Online (Sandbox Code Playgroud)

谢谢你们。

visual-studio

7
推荐指数
1
解决办法
1766
查看次数

functools.wraps有什么作用?

对另一个问题的答案的评论中,有人说他们不确定functools.wraps在做什么.所以,我问这个问题,以便在StackOverflow上有一个记录,供将来参考:究竟functools.wraps做了什么?

python decorator functools

588
推荐指数
6
解决办法
12万
查看次数

比较VB.NET中的对象

我想编写一个接受两个对象作为参数的函数,并仅比较对象中包含的字段.我不知道对象在设计时会是什么类型,但传递的对象将是我们的应用程序中使用的类.

是否可以比较对象的字段而不知道它们在运行时的类型?

vb.net

4
推荐指数
1
解决办法
1万
查看次数

如何将窗户拉到前面?

当远程控制机制激活应用程序中的某些内容时,我们需要将Java应用程序带到前台.

为了得到这个,我们在类的被调用方法中实现了代表我们的应用程序的框架(a的扩展JFrame)在实现之后:

setVisible(true);
toFront();
Run Code Online (Sandbox Code Playgroud)

在Windows XP下,这在第一次调用时工作,第二次只有任务栏中的选项卡闪烁,框架不再出现在前面.Win2k也是如此.在Vista上似乎工作正常.

你有什么想法?

java windows swing awt

90
推荐指数
6
解决办法
14万
查看次数

启用排序时的 ASP.NET GridView CSS 问题

I created a GridView in an ASP.NET application and used the Auto Format tool to apply an attractive style. Now I'm moving the style markup to the CSS sheet and I'm having a weird problem where the text in the header row isn't the correct color (it should be white but it shows up a bright blue). This problem only shows up when I turn sorting on.

Everything else works fine. For example, I can change the header background to …

css asp.net gridview

4
推荐指数
1
解决办法
2万
查看次数

运行Jar文件时出现问题

我已经将一个java项目编译成一个Jar文件,并且在运行它时遇到了问题.

当我跑:

java -jar myJar.jar
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

Could not find the main class: myClass
Run Code Online (Sandbox Code Playgroud)

类文件不在jar的根目录中,所以我尝试更改主类的路径以匹配类文件的路径,我得到了同样的问题.

我应该扁平化文件结构吗?如果是这样我该怎么做 如果有任何用途,我正在使用Ant来构建Jar文件.

UPDATE

这是jar的内容和相关的Ant部分,我已经将我工作的公司名称改为"org":

META-INF/
META-INF/MANIFEST.MF
dataAccessLayer/
dataAccessLayer/databaseTest.class
org/
org/eventService/
org/eventService/DatabaseObject.class
org/eventService/DatabaseObjectFactory.class
org/eventService/DbEventClientImpl$HearBeatMonitor.class
org/eventService/DbEventClientImpl.class
org/eventService/EmptyQueryListException.class
org/eventService/EventHandlerWorkItem.class
org/eventService/EventProcessor.class
org/eventService/EventTypeEnum.class
org/eventService/EventWorkQueue$MonitorThread.class
org/eventService/EventWorkQueue$PoolWorker.class
org/eventService/EventWorkQueue.class
org/eventService/FailedToLoadDriverException.class
org/eventService/IConnectionFailureListener.class
org/eventService/InvalidEventTypeException.class
org/eventService/JdbcInterfaceConnection.class
org/eventService/NullArgumentException.class
org/eventService/OracleDatabaseObject.class
org/eventService/ProactiveClientEventLogger.class
org/eventService/ProactiveClientEventLoggerException.class
org/eventService/PropertyMap.class
org/eventService/SQLServerDatabaseObject.class
org/eventService/TestHarness.class
org/eventService/Utilities.class
Run Code Online (Sandbox Code Playgroud)

而蚂蚁目标:

<target name="compile" depends="init" description="compile the source ">
    <javac srcdir="src" destdir="bin" classpathref="project.class.path"/>
</target>
<target name="buildjar" description="build jar file" depends="compile">
    <mkdir dir="dist"/>
    <jar destfile="dist/myJar.jar" basedir="bin" includes="**/*.class" >
        <manifest>
            <attribute name="Main-Class" value="org.eventService.ProactiveClientEventLogger"/>
        </manifest>
     </jar>
</target>
Run Code Online (Sandbox Code Playgroud)

java ant jar mainclass

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

搜索所有子类型的程序集?

我想找到从基础/接口继承的所有类型.有人有一个很好的方法来做到这一点?想法?

我知道这是一个奇怪的请求,但它是我正在玩的东西.

c# reflection

3
推荐指数
1
解决办法
1904
查看次数

你如何创建一个切换按钮?

我想用hss在html中创建一个切换按钮.我想要它,以便当你点击它时,它会保持推入状态,而当你再次点击它时,它会弹出.

如果没有办法只使用CSS.有没有办法用jQuery做到这一点?

html css jquery

94
推荐指数
7
解决办法
22万
查看次数

Symbian S60第5版虚拟键盘:使用哪种API?

如何(即使用哪个API)是在Symbian S60第5版上打开的虚拟键盘?文档似乎缺乏相关信息.

keyboard virtual symbian

6
推荐指数
1
解决办法
4825
查看次数