验证失败时我的应用程序需要发出蜂鸣声,因此用户(可能在几英尺之外)可能会听到它.我想使用Console.Beep()但是在x64环境中不可用(请参阅备注).计算机中可能有也可能没有扬声器,所以我不能使用System.Media.SystemSounds.Beep.Play().
当前的目标平台是x86环境,但我希望能够让应用程序在x64中运行.
有没有办法做到这一点,还是我应该放弃?
编辑:添加了方法的链接.
我有两个三维点.
例:
float[] point1 = new float[3] {1.3919023, 6.12837912, 10.391283};
float[] point2 = new float[3] {48.3818, 38.38182, 318.381823};
Run Code Online (Sandbox Code Playgroud)
有人想知道算法计算点之间的浮点距离吗?
在我的注册表中我有
Scan(scanner =>
{
scanner.AssemblyContainingType<EmailValidation>();
scanner.ConnectImplementationsToTypesClosing(typeof(IValidation<>));
});
Run Code Online (Sandbox Code Playgroud)
我应该做些什么来将这些全部定义为单身人士?
另外,作为这个问题的一小部分,有没有理由不将无状态的所有内容定义为在StructureMap中注册的单例对象?
以为我会问知识渊博的StackOverflow社区一个我今天想到的问题,我似乎无法找到答案.
"IN"或"OR"之间是否有任何性能差异或优势?
IE浏览器.是
SELECT类型FROM类型WHERE typecat IN('abc','def')
比...更好
SELECT类型FROM类型WHERE typecat ='abc'或typecat ='def'
添加:使用SQL Server 2008
我有一个包含多个变量的数据框,而这些变量又有多个类别.我想把每个类别转换成指标变量.
V1 V2 V3 V4 xc ab ty ky xc ab ty kj xc yi tf kj cv yi tf kj bg yt tg kl bg yu yu kl
转换成
xc cv bg ..... T F F...... T F F.... T F F.... F T F.... F F T... F F T....
我试过了
newframe <- transform(oldframe, xc = to_column(oldframe$V1,'xc'))
Run Code Online (Sandbox Code Playgroud)
列的位置
to_column = function(col, val){
if (col == val)
'TRUE' else
'FALSE' }
Run Code Online (Sandbox Code Playgroud) 我想为我的网络应用程序编写一些测试用例,但是在某些情况下,例如"此令牌应该在30天内过期".没有人喜欢在测试结束前等待30天.
还有一些关于某些预定事件发生的情况,例如"在用户注册后2周发送此电子邮件","在下一个结算日期前2天生成帐单"等.
在编写此类测试用例时,您有什么建议?或者,是否有另一种方法可以确保这些功能与设计一样精确?
是否可以测试另一个属性的代码中是否存在属性?
假设您有以下类定义:
public class Inception {
[Required]
[MyTest]
public int Levels { get; set; }
}
public class MyTestAttribute : ValidationAttribute {
public override bool IsValid(object o){
// return whether the property on which this attribute
// is applied also has the RequiredAttribute
}
}
Run Code Online (Sandbox Code Playgroud)
... MyTestAttribute.IsValid是否可以确定Inception.Levels是否具有RequiredAttribute?
我开始做以下事情:
using (TextWriter textWriter = new StreamWriter(filePath, append))
{
foreach (MyClassA myClassA in myClassAs)
{
textWriter.WriteLine(myIO.GetCharArray(myClassA));
if (myClassA.MyClassBs != null)
myClassA.MyClassBs.ToList()
.ForEach(myClassB =>
textWriter.WriteLine(myIO.GetCharArray((myClassB)));
if (myClassA.MyClassCs != null)
myClassA.MyClassCs.ToList()
.ForEach(myClassC =>
textWriter.WriteLine(myIO.GetCharArray(myClassC)));
}
}
Run Code Online (Sandbox Code Playgroud)
这似乎很慢(35,000行约35秒).
然后我尝试按照这里的示例创建一个缓冲区,使用以下代码,但它没有获得任何东西.我仍然看到大约35秒的时间.我是如何实现缓冲区的?
using (TextWriter textWriter = new StreamWriter(filePath, append))
{
char[] newLineChars = Environment.NewLine.ToCharArray();
//Chunk through 10 lines at a time.
int bufferSize = 500 * (RECORD_SIZE + newLineChars.Count());
char[] buffer = new char[bufferSize];
int recordLineSize = RECORD_SIZE + newLineChars.Count();
int bufferIndex = 0; …Run Code Online (Sandbox Code Playgroud) 码:
public Thread ThreadReceive;
ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
ThreadReceive.Start()
Public Sub ReceiveMessages()
Try
Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
txtIP.Text = RemoteIpEndPoint.Address.ToString
Dim BitDet As BitArray
BitDet = New BitArray(receiveBytes)
Catch e As Exception
Console.WriteLine(e.Message)
End Try
End Sub
Run Code Online (Sandbox Code Playgroud)
任何人都可以建议我如何转换这一行:
ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
Run Code Online (Sandbox Code Playgroud)
vb到C#
谢谢,巴沙.
我真的很奇怪.我已经创建了新的aspx页面,并且没有使用任何自定义逻辑对象(使用visual studio向导创建的所有内容)尝试从sqldatasource创建网格视图.
数据来自存储过程,单个参数具有默认值.当我刷新架构或单击"测试查询"时,我看到结果行和GridViews字段是核心创建的.但是当我运行页面时,没有网格视图(它只是空的 - 当我添加EmptyDataTemplate时会显示它).我添加了自定义(空)函数和DataBind,DataBinded和RowCreted事件,并且只触发了databind和datavound事件(尽管如我所写 - 存储过程及其默认参数返回行和.net可以在设计模式下读取它们)
程序中没有任何"花哨"的东西,我已经多次这样做了没有问题.我已经尝试了另一个在我们的生产环境中工作的存储过程,并且仍然具有相同的emty gridview
这是代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TEST.aspx.cs" Inherits="site.TEST" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AllowSorting="True" OnDataBinding="GridView1_DataBinding" OnDataBound="GridView1_DataBound"
OnRowCreated="GridView1_RowCreated">
<EmptyDataTemplate>
No Data Available
</EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>"
SelectCommand="myStoredProcedure" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter DefaultValue="val1" Name="par1" Type="String" />
<asp:Parameter Name="val2" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
和代码隐藏
using System;
using System.Collections; …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×2
64-bit ×1
asp.net ×1
beep ×1
gridview ×1
lifecycle ×1
r ×1
reflection ×1
sql ×1
structuremap ×1
syntax ×1
textwriter ×1
unit-testing ×1
vb.net ×1
windows ×1