我想创建一个通用的DateTime正则表达式,它将匹配所有可能的C#DateTime格式,如Microsoft的TryParse.
MM/dd/Year
dd/MM/Year
dd/MM/YY
MM/dd/YY
dd/MM/Year hh:mm
...
Run Code Online (Sandbox Code Playgroud)
你有什么建议吗?如果它很简单,我也可以将日期与时间分开.并为Date创建正则表达式,为Time创建一个正则表达式.
我有一个复杂的算法,它从套接字连接接收数据,转换数据并尽快将其存储在HD上.由于这一事实,我不希望处理速度减慢的数据是通过使用不同的线程.数据存储算法类似于这种结构.它基本上将XML保存在磁盘上.
Begin Thread
beginthread:
XmlTextWriter xmltextWriter;
Save Xml file 1
xmltextWrite.close();
XmlTextWriter xmltextWriter;
Save Xml file 2
xmltextWrite.close();
goto beginthread:
End Thread
Run Code Online (Sandbox Code Playgroud)
它工作正常,但如果我看一下任务管理器,我可以注意到我的程序消耗的内存量随着时间的推移而迅速增加(工作1小时后为500mb).这可能是合理的,因为线程没有进入的数据那么快,.NET框架为我存储临时内存.但我不明白为什么如果传入的套接字连接将停止,即使几分钟后线程继续工作......任务管理器继续显示500Mb的内存..为什么内存没有被重新启动?!XmlTextWriter对象是一个局部变量,每次都会关闭.
按要求..这是代码的一部分
beginthread:
if (sleeptime < 1000) sleeptime += 2;
try
{
while (hashBeginConn.Count > 0)
{
sleeptime = 0;
int connToApply = hashBeginConn[0];
if (olddate.ToShortDateString() != ListsockConnections[connToApply].beginDate.ToShortDateString())
{
JoinDataFromTempFile(ListsockConnections[connToApply].beginDate.Date.Subtract(olddate.Date).Days, false, d);
olddate = ListsockConnections[connToApply].beginDate.Date;
}
if (tocreate)
{
// XML Serialization
XmlTextWriter xmltextWriter;
Encoding enc = null;
if (ListsockConnections[connToApply].ENCfromCode) enc = Encoding.GetEncoding(ListsockConnections[connToApply].codepage);
if (ListsockConnections[connToApply].ENCDefault) enc = Encoding.Default; …Run Code Online (Sandbox Code Playgroud) 我试图在轴上旋转一个波,但不知怎的,如果我将传递到sin并且cos值大于45,波似乎会失真或者函数没有以适当的角度旋转.
...
wave
// ROtate
for (int i=0; i<300; i++){
coordinatesX[i] = ((coordinatesX[i] * (float)Math.cos(60)) - (coordinatesY[i] * (float)Math.sin(60))) + coordinatesX[i];
coordinatesY[i] = (coordinatesX[i] * (float)Math.sin(60)) + (coordinatesY[i] * (float)Math.cos(60)) + coordinatesY[i];
}
Run Code Online (Sandbox Code Playgroud)
这是整个代码:
// define newpath
float[] coordinatesX = new float[300];
float[] coordinatesY = new float[300];
// wave
for (int i=0; i<300; i++){
coordinatesX[i] = i;
coordinatesY[i] = (float)(20 * (Math.sin((-0.10 * coordinatesX[i]))));
System.out.println(coordinatesX[i]);
System.out.println(coordinatesY[i]);
}
// ROtate
for (int i=0; i<300; i++){
coordinatesX[i] = ((coordinatesX[i] * (float)Math.cos(-10)) - …Run Code Online (Sandbox Code Playgroud) 我有这个代码:
NSMutableData *derivedKey = [NSMutableData dataWithLength:32];
// code missing..fill somehow the derivedKey with 32 random bytes
// This line doesn't crash
NSData *iv = [derivedKey subdataWithRange:NSMakeRange(0, 32)];
Run Code Online (Sandbox Code Playgroud)
..
// This line crashes
NSData *iv = [derivedKey subdataWithRange:NSMakeRange(16, 32)];
Run Code Online (Sandbox Code Playgroud)
有什么建议为什么会这样?似乎只有0到32遍的整个范围我想简单一个新的NSData变量,它只包含字节的后半部分
我想能够使用XmlTextWriter或LINQ to XML编写XML文件,但我不希望文件被完全锁定.我想其他进程能够读取Xml文件.它应该仅在写入模式下锁定,以便其他人不能修改文件.实现这一目标的最佳方法是什么?
我想用图像填充像圆形或自定义路径的路径,但想要拉伸图像,以便图像的像素不会位于闭合路径之外.这可以使用Canvas对象在HTML5中实现吗?
这是我的自定义路径:
ctx.beginPath();
ctx.moveTo(170, 80);
ctx.bezierCurveTo(130, 100, 130, 150, 230, 150);
ctx.bezierCurveTo(250, 180, 320, 180, 340, 150);
ctx.bezierCurveTo(420, 150, 420, 120, 390, 100);
ctx.bezierCurveTo(430, 40, 370, 30, 340, 50);
ctx.bezierCurveTo(320, 5, 250, 20, 250, 50);
ctx.bezierCurveTo(200, 5, 150, 20, 170, 80);
// complete custom shape
ctx.closePath();
ctx.lineWidth = 5;
ctx.fillStyle = '#8ED6FF';
ctx.fill();
ctx.strokeStyle = 'blue';
ctx.stroke();
Run Code Online (Sandbox Code Playgroud)
我想要实现的是用图像填充云,但要拉伸它.如果它看起来很难看并不重要.
我有这个代码:
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static void Main()
{
List<Holiday> holidayDifference = new List<Holiday>();
List<Holiday> remoteHolidays = new List<Holiday>
{
new Holiday { Name = "Xmas", hello ="aproperty" },
new Holiday { Name = "Hanukkah", hello ="hello" },
new Holiday { Name = "Ramadan" }
};
List<Holiday> localHolidays = new List<Holiday>
{
new Holiday { Name = "Xmas", hello="different" },
new Holiday { Name = "Ramadan", hello="hello" }
};
holidayDifference = remoteHolidays
.Except(localHolidays) …Run Code Online (Sandbox Code Playgroud) .net ×4
c# ×4
andengine ×1
canvas ×1
game-physics ×1
html5 ×1
html5-canvas ×1
java ×1
linq ×1
linq-to-xml ×1
objective-c ×1
optimization ×1
regex ×1
sockets ×1