对不起,不知道长度是在施工时计算的!
我得到200个字符串长的字符串A,5个字符串长字符串B如果我这样做
int Al = A.length;
int Bl = B.length;
Run Code Online (Sandbox Code Playgroud)
并且比较它 - 一切似乎都很好但是如果我这样做几百万次来计算某些东西,它对于我需要的东西来说太昂贵了.
更简单和更简洁的方法是可以比较两个字符串的一些功能,并告诉我何时另一个是至少与另一个相同.类似于(compare_string_lengths(stringA,stringB) - >其中字符串B必须至少与字符串A一样长(字符)才能为函数返回TRUE.
是的,我知道函数不知道哪个字符串更短,但是如果两个字符串的长度将被并行计数,那么当一个字符串超过另一个时,函数知道要"回答"的内容.
谢谢你的任何提示.
今天我读了一篇文章,其中写道我们应该总是使用TryParse(字符串,输出MMM)进行转换而不是Convert.ToMMM().
我同意文章,但之后我陷入了一个场景?
当字符串总是有一些有效值时,我们也可以使用Convert.ToMMM(),因为我们没有从Covert.ToMMM()中获得任何异常.
我想知道的是:当我们使用TryParse时是否有任何性能影响因为当我知道out参数总是有效时我们可以使用Convert.ToMMM()而不是TryParse(字符串,输出MMM)
你怎么看?
这是我的目录结构:
-根
--docs
--- doc1.php
--includes
---的header.php
--- footer.php
--- css.css
--index.php
在我的标题中,我链接到我的CSS文件,如下所示:
<link href="includes/styling.css" type="text/css" rel="stylesheet" />
Run Code Online (Sandbox Code Playgroud)
这适用于index.php,因为它是正确的路径(root/includes/css.css).
但是对于doc1.php来说,这不是正确的道路.(根/文档/包括/ css.css).
如何在保留一个包含该行代码的header.php文件的同时修复此问题?有没有办法强制路径在根目录中启动?
我想阅读一些库文件,然后我去了工具>选项>项目和解决方案> VC++目录,我发现了以下内容:
$VSInstalldir/...
$VSInstalldir/...
$FrameworkSDKdir/
$WindowsSDKdir/...
$PATH
$SystemRoot/Syswow64/....
Run Code Online (Sandbox Code Playgroud)
我只能在$ VSInstalldir中找到文件.$ FrameworkSDKdir,$ WindowsSDKdir,$ PATH,$ SystemRoot/Syswow64应该在哪里?
我需要得到我的DataContext的子类,我找到了下面的函数,它位于某处,它确实找到了我的子类但我无法实例化它:(
public static IEnumerable<T> GetSubclassesFor<T>(Assembly assembly)
{
return (assembly.GetTypes()
.Where(t => t.BaseType == (typeof (T)))
.Select(t => (T) Activator.CreateInstance(t, new object[] {"asdasd"})))
.ToList();
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误消息:
System.Reflection.TargetInvocationException:ETT undantagsfel HARinträffat我MALET当EN aktivering.----> System.TypeInitializationException:TypinitierarenFÖRPlaynGO.Cashier.Data.CashierDCutlösteETT undantag.----> System.NullReferenceException:Objektreferensen har inte angetts直到en instans av ett objekt.vid System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo方法,对象[]指定参数时,REF SignatureStruct签名,RuntimeType declaringType)VID System.Reflection.RuntimeConstructorInfo.Invoke(的BindingFlags invokeAttr,粘结剂粘结剂,对象[]参数,CultureInfo的培养物)VID System.RuntimeType.CreateInstanceImpl(的BindingFlags bindingAttr,粘合剂粘合剂,对象[]指定参数时,CultureInfo的文化,对象[] activationAttributes)VID System.Activator.CreateInstance(类型类型,对象[]参数)VID PlaynGO.Dbml.Reflexion.b _3(T型)1 Reflexion.cs:线23 vid System.Linq.Enumerable.WhereSelectArrayIterator
2.MoveNext() vid System.Collections.Generic.List1..ctor(IEnumerable1 collection) vid System.Linq.Enumerable.ToList(IEnumerable1个源)VID PlaynGO.Dbml.Reflexion.GetInstances(大会组件)1 Reflexion.cs:线23个VID PlaynGO.Dbml.UnitTests.TestReflection.TestGettingTypes()1 TestReflection.cs:线21个--TypeInitializationException VID PlaynGO.Cashier.Data .CashierDC..ctor(String connection) - nullReferenceException vid PlaynGO.Cashier.Data.CashierDC..cctor()
我想调用的构造函数如下:
public CashierDC(string connection) : …Run Code Online (Sandbox Code Playgroud) 我试图通过文本框通过aspx页面插入参数.我设置了我的参数,但是evertime I executenonquery,@ Username显示在数据库中而不是实际值.以下是我的代码.任何人都可以有点洞察力吗?
这是完整的代码:
protected void btn_SubmitUserInfo_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=c:\\Documents and Settings\\xm\\My Documents\\Visual Studio 2010\\Projects\\CreateUser\\CreateUser\\App_Data\\UserInformation.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True; Integrated Security=SSPI");
//Open the connection outside of the try statement
conn.Open();
try
{
//Create a command for the stored procedure and tie it into the connection
SqlCommand cmd = new SqlCommand("InsertUserValues", conn);
//Set the command type so it know to execute the stored proc
cmd.CommandType = CommandType.StoredProcedure;
//Declare Parameters
SqlParameter …Run Code Online (Sandbox Code Playgroud) 我在函数的最后一行得到一个例外,这个例外与free有关.这是:Windows在HW1.exe中触发了断点.
这可能是由于堆的损坏,这表明HW1.exe或其加载的任何DLL中存在错误.
这也可能是由于用户在HW1.exe具有焦点时按下F12.
输出窗口可能包含更多诊断信息.
void unicode(HANDLE file, DWORD sizeOfFile, int N) {
if(sizeOfFile - 2 == 0)
return;
_TCHAR* text = (_TCHAR*)malloc(sizeOfFile);
DWORD numRead = 0;
BOOL read = ReadFile(file, text, sizeOfFile, &numRead, NULL);
assert(read && (sizeOfFile == numRead));
int i = 0;
int lineNum = 0;
int lineStart = 0;
text++;
sizeOfFile--;
while(i <= sizeOfFile / 2) {
if(i == sizeOfFile / 2 && lineNum < N)
printLineUnicode(text + lineStart, i - lineStart, lineNum++);
else if(text[i] == '\r') { …Run Code Online (Sandbox Code Playgroud) 我有一个申请.
首先,我显示一个启动画面,一个表单,这个启动会调用另一个表单.
问题:当显示启动窗体时,如果我然后在启动画面顶部打开另一个应用程序,然后最小化这个新打开的应用程序窗口,则启动画面变为白色.我该如何避免这种情况?我希望我的飞溅能够清晰显示,不受任何应用程序的影响.
我的代码如下
public class SessionCheckAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (/*condition*/)
{
filterContext.HttpContext.Response.Redirect("http://www.someurl.com",true);
}
base.OnActionExecuting(filterContext);
}
}
Run Code Online (Sandbox Code Playgroud)
现在,问题是为什么[SessionCheck]的操作应用于它STILL执行.有任何想法吗?谢谢.
我正在使用它来下载文件并获取%信息和完成的信息.我想知道如何获取正在下载的文件的大小以及URL远程地址和保存文件的本地地址.
private void Form1_Load_1(object sender, EventArgs e)
{
label21.Text = "Download in progress...";
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
webClient.DownloadFileAsync(new Uri("http://www.somesite.com/Update/Updates.zip.010"), @"Updates.zip.010");
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Value = e.ProgressPercentage; //Progress Bar Handler
label1.Visible = true;
label1.Text = progressBar1.Value.ToString() + " %"; //Adds percent to a label
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
label11.Visible = true;
label11.Text = "Done";
}
Run Code Online (Sandbox Code Playgroud)