我有一个系列:
System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Area
Run Code Online (Sandbox Code Playgroud)
如何使该区域透明,以便我可以看到其他先前绘制的系列?
在打开Windows窗体和控制台的C#应用程序中,为什么每当关闭From时调用Finalizer,而不是在控制台关闭时调用?即使从控制台关闭应用程序,有没有办法调用Finalizer?
我在创建一个在Construction上创建文件的类并在Dispose/Finalize上删除文件时注意到了这一点.关闭表单时,它按预期工作,但正在创建文件但关闭控制台时未删除.
编辑
我必须对这些条款感到困惑.这是我的临时文件代码:
class TemporaryFile : IDisposable {
private String _FullPath;
public String FullPath {
get {
return _FullPath;
}
private set {
_FullPath = value;
}
}
public TemporaryFile() {
FullPath = NewTemporaryFilePath();
}
~TemporaryFile() {
Dispose(false);
}
private String NewTemporaryFilePath() {
const int TRY_TIMES = 5; // --- try 5 times to create a file
FileStream tempFile = null;
String tempPath = Path.GetTempPath();
String tempName = Path.GetTempFileName();
String fullFilePath = Path.Combine(tempPath, tempName);
try {
tempFile = System.IO.File.Create(fullFilePath); …Run Code Online (Sandbox Code Playgroud) 有一段我的代码被重复调用(每秒2000+).为了避免垃圾生成并降低性能开销,我将所有局部变量都移到了类级别,但我不确定这种方法是否有效......
我的问题是......
我正在尝试改进我的应用程序并提高它的性能.基本上,它是一个高级的Graph-class.它绘制了几行并刷新它们.
在确定了几个慢点之后,我想对我的结果进行基准测试.我的绘图卡在~65 FPS(这是完美的,但我是基准测试).我在一个计时器(设置为1毫秒)中使我的对象无效,并使用受保护的覆盖void OnPaint - "way"重绘我的东西.
之后,我将Invalidate()放入受保护的覆盖void OnPaint中.事后FPS设定为几千.但使用该方法将导致空屏幕.
我的问题是:这个问题是故意的吗?这是有道理的,因为高于屏幕刷新率的任何东西都是浪费的力量.但我想为我的基准测试禁用"锁定".
示例代码:
//Timer to refresh
private void timer1_Tick(object sender, EventArgs e)
{
Invalidate();
}
private DateTime date = DateTime.UtcNow;
private long times = 0;
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//Drawing
e.Graphics.DrawLine(new Pen(Brushes.Black), 50, 50, Width - 100, Height - 100);
//Required to tell me the framerate
if ((DateTime.UtcNow - date).Seconds > 1)
{
date = DateTime.UtcNow;
Debug.WriteLine(times);
times = 0;
}
times++;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
史蒂夫〜
我正在设计应用程序的后端,我想从数据库中获取不同的类别.我使用以下查询:
var categories = from source in vm.Sources select source.Source_Category.ToList().Distinct();
Run Code Online (Sandbox Code Playgroud)
我的模型有四个字段,分别是(Source_Name,Source_Link,Source_Subscribed,Source_Category)
该模型共包含4个条目,其中两个属于"新闻"类别,另外两个属于"科学".但是使用上面的查询我得到所有四个条目,理想情况下它应该只返回两个项目.我哪里出错了?
我有一个方法(在类中),它传递2个整数,然后返回设置为2D网格的锯齿状数组中"坐标"的值.因此,例如,GetXY(5,6)将返回在该位置发生的任何整数值.
在方法中,我有一个if语句,它检查传递的值是否低于零或高于数组的大小,并throw new在值为的情况下抛出异常.
代码部分工作,除了它只检测行何时是错误的值,并且当列的值不正确时什么也不做.
这是我的代码(grid在类构造函数中创建):
public int GetXY(int row, int column)
{
int[] items = grid[column];
if (row < 0 || column < 0 || row >= grid.Length || column >= items.Length)
{
throw new Exception("The passed coordinates are outside the range of the grid. " +
"Passed coordinates: " + row.ToString() + "," + column.ToString() + ".");
}
return grid[row][column];
}
Run Code Online (Sandbox Code Playgroud)
当我执行GetXY(10,9)(10x10)网格时,我得到自定义异常消息,除非我执行GetXY(9,10),我得到:
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the boun
ds of the …Run Code Online (Sandbox Code Playgroud) 我想通过 adb 启动我的应用程序的应用程序信息屏幕。我尝试使用“adb shell am start”来触发意图,但似乎没有任何效果。我需要至少适用于 API 级别 18 和 19 的东西。有人可以帮忙吗?
List<Candidate> candidates = (List<Candidate>) session.createSQLQuery("select candidate.* from candidate inner join candidate_skill on candidate.id = candidate_skill.candidate_id inner join skill on candidate_skill.skill_id = skill.id where skill.id = 1");
Run Code Online (Sandbox Code Playgroud)
我明白了:
java.lang.ClassCastException: org.hibernate.internal.SQLQueryImpl cannot be cast to java.util.List
Run Code Online (Sandbox Code Playgroud)
查询是正确的.怎么解决?
如果我们在我们的程序中只有一个类,而不扩展任何类.例如
public class Point {
int x, y;
}
Run Code Online (Sandbox Code Playgroud)
编译器创建默认构造函数并根据此http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.9调用super()方法
public class Point {
int x, y;
public Point() {
super();
}
}
Run Code Online (Sandbox Code Playgroud)
问:据我所知super(); 调用超类的默认构造函数,但在这种情况下我们没有超类,那么在这种情况下什么是super()调用?