在整个网络上,代码示例都有如下所示的for
循环:
for(int i = 0; i < 5; i++)
Run Code Online (Sandbox Code Playgroud)
我使用以下格式:
for(int i = 0; i != 5; ++i)
Run Code Online (Sandbox Code Playgroud)
我这样做是因为我认为它更有效率,但这在大多数情况下真的很重要吗?
我有一个DispatcherTimer我已初始化如下:
static DispatcherTimer _timer = new DispatcherTimer();
static void Main()
{
_timer.Interval = new TimeSpan(0, 0, 5);
_timer.Tick += new EventHandler(_timer_Tick);
_timer.Start();
}
static void _timer_Tick(object sender, EventArgs e)
{
//do something
}
Run Code Online (Sandbox Code Playgroud)
_timer_Tick事件永远不会被解雇,我错过了什么吗?
在我的machine.config文件中,我有以下内容
<configuration>
....
<appSettings>
<add key="key" value="value"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我试图通过使用在asp页面上检索它
ConfigurationManager.AppSettings["key"];
Run Code Online (Sandbox Code Playgroud)
并且每次都返回null.
我有一个绘制和旋转立方体的类.每次我旋转立方体时,我都会使用多维数据集的新值重新加载缓冲区.
public void LoadBuffer(GraphicsDevice graphicsDevice)
{
buffer = new VertexBuffer(graphicsDevice, VertexPositionNormalTexture.VertexDeclaration, triangles * 3, BufferUsage.None);
buffer.SetData<VertexPositionNormalTexture>(verts);
graphicsDevice.SetVertexBuffer(buffer);
}
public void Draw(GraphicsDevice graphicsDevice)
{
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, triangles);
}
Run Code Online (Sandbox Code Playgroud)
然后在Game.Draw中调用Cube.Draw方法
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(ClearOptions.DepthBuffer | ClearOptions.Target, Color.White, 1f, 0);
basicEffect.Parameters["WorldViewProj"].SetValue(world * view * projection);
EffectPass pass = basicEffect.CurrentTechnique.Passes[0];
if (pass != null)
{
pass.Apply();
cube1.LoadBuffer(GraphicsDevice);
cube1.Draw(GraphicsDevice);
cube2.LoadBuffer(GraphicsDevice);
cube2.Draw(GraphicsDevice);
cube3.LoadBuffer(GraphicsDevice);
cube3.Draw(GraphicsDevice);
}
base.Draw(gameTime);
}
Run Code Online (Sandbox Code Playgroud)
几分钟左右后,我得到一个OutOfMemory Exception就行了:
buffer.SetData<VertexPositionNormalTexture>(verts);
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么会发生这种情况以及我能做些什么来解决它.
为什么有两个不同的逻辑运算符似乎做同样的事情(<=&!>),是否有任何情况会优先于另一个?
我目前正在尝试对用户音乐收藏进行分类,并且能够获得用户最常播放的歌曲/艺术家将极大地改善应用中的用户体验.是否有可能获得比赛的数量?我该怎么做呢
我正在尝试编写一个关闭资源管理器然后运行另一个程序的程序.
我在尝试使用以下代码关闭资源管理器时遇到问题:
foreach (Process p in Process.GetProcesses())
if (p.MainModule.ModuleName.Contains("explorer"))
p.Kill();
Run Code Online (Sandbox Code Playgroud)
有人可以让我知道为什么这样做并提供解决方案
CHEERS
ps这不是一个恶意程序,它将运行一个游戏,当探险家在后台时,该游戏无法正常工作
我有这个SQL,我正在尝试将一个人的登录名表加入到包含多个用户ID的任务表中
SELECT Task.TaskID
,Project.Project
,Task.Task
,Task.Description
,Task.OwnerLoginID //shown as Login.UserName
,Task.SubmitterID //shown as Login.UserName
,Task.IsVisible
FROM Task
INNER JOIN Project ON Task.ProjectID = Project.ProjectID
/*
INNER JOIN Login ON Task.SubmitterID = Login.LoginID
INNER JOIN Login ON Task.OwnerLoginID = Login.LoginID
*/
WHERE IsVisible = 1
Run Code Online (Sandbox Code Playgroud)
我在底部的注释掉的行中出错了我错了吗?
我的家庭控制器中有以下操作.当我发布到GetDistance()
它时,它永远不会进入/ Home/ShowDistance页面,而是停留在/ Home/Index页面上.我已经检查过lat
和lon
值不为null,因此浏览器应该重定向到/ Home/ShowDistance.
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult GetDistance(string lat, string lon)
{
if (lat != null && lon != null)
{
Session["latlon"] = new LatLon { Latitude = double.Parse(lat), Longitude = double.Parse(lon) };
return RedirectToAction("ShowDistance");
}
return RedirectToAction("Index");
}
public ActionResult ShowDistance()
{
//...
return View();
}
Run Code Online (Sandbox Code Playgroud) 我不想使用XMLDocument,因为我使用XMLWriter编写了XML编写代码.因此,没有理由切换.
<Player>
<Friends />
<Ignores>
<Ignore>117779</Ignore>
<Ignore>44237636758361374</Ignore>
<Ignore>564534831</Ignore>
</Ignores>
<InventoryItems>
<Item>
<Slot>0</Slot>
<Id>995</Id>
<Amount>39493</Amount>
</Item>
<Item>
<Slot>27</Slot>
<Id>1049</Id>
<Amount>12</Amount>
</Item>
</InventoryItems>
<BankItems />
</Player>
Run Code Online (Sandbox Code Playgroud)
我正在尝试解析那里.这是我到目前为止所得到的.似乎在任何地方打破了我有点工作<Ignore>'s
但是当我使用ReadToFollowing
而不是ReadToNextSibling
,它会工作,直到ReadToFollowing击中一个空行..它只会达到EOF.
XmlTextReader reader = new XmlTextReader(misc.getServerPath() + "\\accounts\\" + username + ".xml");
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Friends") {
if (!reader.IsEmptyElement) //got any friends
{
while (reader.ReadToFollowing("Friend"))
//do_stuff_with_that_data(reader.ReadElementContentAsLong());
}
} else if (reader.NodeType == XmlNodeType.Element && reader.Name == "Ignores") {
if (!reader.IsEmptyElement) //got any ignores …
Run Code Online (Sandbox Code Playgroud)