它有一个属性:字符串代码和其他10个.
公共代码是字符串列表(string [])汽车列表(Car [])filteredListOfCars是List.
for (int index = 0; index < cars.Length; index++)
{
Car car = cars[index];
if (commonCodes.Contains(car.Code))
{
filteredListOfCars.Add(car);
}
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这片方法的时间太长了.
我有大约5万条记录
我怎样才能降低执行时间?
我用的是:
total_time=datetime.time(int(total_time_text.replace("h","").replace("m","").split(" ")[0]),int(total_time_text.replace("h","").replace("m","").split(" ")[1]),0)
Run Code Online (Sandbox Code Playgroud)
存储时间长度.
但是当我有:
total_time_text ="26h 50m"
Run Code Online (Sandbox Code Playgroud)
我得到一个例外
'hour must be in 0..23'
Run Code Online (Sandbox Code Playgroud)
所以类型"时间"不适合这个var.我必须使用什么?
我在 web.config 中有 3 个连接字符串,我这样使用它们:
using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SomeName"].ConnectionString))
Run Code Online (Sandbox Code Playgroud)
每个metgod 都由winforms 应用程序调用。
一种 webmethods 无法正常工作,因为它只读取一个连接字符串:
data source=.\\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
Run Code Online (Sandbox Code Playgroud)
它不是我的 web.config 中的 connectionString 。
我以相同的方式调用每个方法。
怎么不可能??
编辑:
我使用外观: 这是结构: WinForms 调用 WebMethod SaveItem SaveItem 调用外观上的方法: SaveItemAndDoDatabaseStuff SaveItemAndDoDatabaseStuff 执行数据库操作。
我有程序写入数据库文件夹已满或空.现在我正在使用
bool hasFiles=false;
(Directory.GetFiles(path).Length >0) ? hasFiles=true: hasFiles=false;
Run Code Online (Sandbox Code Playgroud)
但这需要将近一个小时,而我现在无能为力.
有没有最快的方法来检查文件夹是否有任何文件?
我为wcf straming提供了wcf服务.我工作.但我必须将它与我们的webserice集成.
有没有办法,有这样的webmethod:
[webmethod]
public Stream GetStream(string path)
{
return Iservice.GetStream(path);
}
Run Code Online (Sandbox Code Playgroud)
我服务是一个类,我从WCF服务复制到我的asmx.
有没有办法将wcf中的App.config与web.config集成?
我有一个遗留代码,我有重构器的问题.
在我的应用程序开始时,我从WCF
属性加载App
(这是SL
应用程序)用户列表.
然后,每个控件(用于发送电子邮件,查看日历和分配任务)都使用此属性
(App.Current as App).Users
Run Code Online (Sandbox Code Playgroud)
现在,我正在尝试为使用此列表的控件之一创建单元测试,而且我被卡住了.
我应该使用App
as参数进行构造函数注入(我使用Unity)吗?或者可能会介绍一些类来保存这个列表?
我有这个方法来散列字符串:
byte[] buffer = enc.GetBytes(text);
SHA1CryptoServiceProvider cryptoTransformSHA1 =
new SHA1CryptoServiceProvider();
string hash = BitConverter.ToString(
cryptoTransformSHA1.ComputeHash(buffer)).Replace("-", "");
return hash;
Run Code Online (Sandbox Code Playgroud)
我的问题是:
对于相同的字符串,结果哈希是否始终相同?
我几天前打了一个字符串,似乎它现在导致另一个哈希,但我不确定.
我无法弄清楚如何以编程方式选择checkboxlist中的项目.
这个cource方法不能编译,但我想告诉你我想得到什么结果.
public ColumnsSelector(Dictionary<string, bool> dataPropertyNames)
: this()
{
foreach (var item in dataPropertyNames)
{
checkedListBox1.Items.Add(item.Key);
checkedListBox1.Items[checkedListBox1.Items.IndexOf(item.Key)].Checked = item.Value;
}
}
Run Code Online (Sandbox Code Playgroud)
你怎么强迫这个问题?
我的行中的值等于-16777056,但是如何将其转换为Color?
像这样的东西:
Color = (Color) Convert.ToInt32(((DataRowView)this.dataGridView1.Rows[e.RowIndex].DataBoundItem)["Color"]) })
Run Code Online (Sandbox Code Playgroud) 我有一个包含两列的行的表
A 1
A 2
B 1
B 3
C 1
C 2
C 3
Run Code Online (Sandbox Code Playgroud)
我想从这个只得到这个ID(a,b或c)只有2行值1,2,所以从这个表我得到一个,因为b没有行2,c有行用1和b,但也有c行...
获取此行的最简单方法是什么?
c# ×7
asmx ×1
casting ×1
checkboxlist ×1
colors ×1
datetime ×1
directory ×1
legacy-code ×1
performance ×1
python ×1
select ×1
sha1 ×1
sql ×1
wcf ×1
web-config ×1
web-services ×1
winforms ×1