小编gun*_*171的帖子

用于数独的锯齿状或多维数组

我想用c#做一个数独.我应该使用锯齿状或多维数组.为什么?

我知道,对于简单的数组逻辑,例如数独,锯齿状数组更快更有效.但也许还有其他争论?

提前致谢.

编辑:我需要在数独上执行一些解决方法.像回溯算法一样.我发现多维数组有更好的语法.

我想我的问题是:哪个最简单易用,实现和修改?

c# jagged-arrays multidimensional-array

0
推荐指数
1
解决办法
614
查看次数

如何在Visual Basic中使用"0"前的数字?

我想在我的程序中打印结果如下:06:03在visual basic中6如何在数字前添加"0"

m=6
h=3 
print m;" : ";h
Run Code Online (Sandbox Code Playgroud)

vb6 vba

0
推荐指数
1
解决办法
497
查看次数

在Java中重用字符串

我一直想知道是否有任何方法可以重用字符串,如:

import java.io.Console;

public class input {
    public static void main (String[] args) {
        Console console = System.console();
        String input = console.readLine("Type username: "); //user input
        // name code
        // clear string
        String input = console.readLine("Hello, what would you like to do: ");  
        // other code
    }
}
Run Code Online (Sandbox Code Playgroud)

通过清除字符串//clear string,所以如果你有一个循环的用户输入,如果一个东西没有出现,它不会中断.

java user-input

0
推荐指数
1
解决办法
656
查看次数

如何使用SHA1散列文件夹

有没有办法使用SHA1来散列包含其中所有内容的文件夹?我能够使用MD5做到这一点,但我担心MD5遭受的冲突.我正在尝试构建一个应用程序来检查本地文件,以查看它们是否与使用哈希的在线版本匹配.

这是我在MD5中使用的代码:

var path = leftCheckTextbox.Text;
var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)
                     .OrderBy(p => p).ToList();

MD5 md5 = MD5.Create();

for (int i = 0; i < files.Count; i++)
{
    string file = files[i];

    string relativePath = file.Substring(path.Length + 1);
    byte[] pathBytes = Encoding.UTF8.GetBytes(relativePath.ToLower());
    md5.TransformBlock(pathBytes, 0, pathBytes.Length, pathBytes, 0);

    byte[] contentBytes = File.ReadAllBytes(file);
    if (i == files.Count - 1)
        md5.TransformFinalBlock(contentBytes, 0, contentBytes.Length);
    else
        md5.TransformBlock(contentBytes, 0, contentBytes.Length, contentBytes,0);
}

leftHash = BitConverter.ToString(md5.Hash).Replace("-", "").ToLower();
Run Code Online (Sandbox Code Playgroud)

c# hash

0
推荐指数
1
解决办法
1923
查看次数

将字符串数组与另一个中的起始值进行比较

我有一个固定值的字符串数组和一个动态更改文本的richtextbox.richtextbox中的某些行以字符串数组中的值开头.我想只选择richtextbox中不以字符串数组中的值开头的行.以下代码返回richtextbox中的所有行.

string[] parts = new string[] { "Definition:", "derivation:", "derivations:"};
IEnumerable<string> lines = richTextBox1.Lines.Where(
c =>parts.Any(b=>!c.StartsWith(b)));
Run Code Online (Sandbox Code Playgroud)

我的问题是:如何只选择不以字符串数组中的值开头的richtextbox的行?

c# linq

0
推荐指数
1
解决办法
181
查看次数

字符串汇总来自sql

我有一个包含大量电子邮件地址的数据库,我需要将它们格式化为一个字符串,如下所示:

toaddress = "name@gmail.com,name1@gmail.com,name2@gmail.com,name3@gmail.com"
Run Code Online (Sandbox Code Playgroud)

当前代码:

string toaddress = "";
using (SqlConnection conn = new SqlConnection(""))
{
    SqlCommand cmd = new SqlCommand("SELECT email FROM dbo.Members", conn);
    conn.Open();
    SqlDataReader rdr = cmd.ExecuteReader();
    while (rdr.Read())
    {
        toaddress = rdr["email"].ToString();
    }
    rdr.Close();
}
Run Code Online (Sandbox Code Playgroud)

c# sql sql-server

0
推荐指数
1
解决办法
103
查看次数

无法弄清楚如何为我的函数使用参数

我目前正在做一个小程序,帮助我理解函数和C#整体.但是,我找不到如何使用我的功能.

我将从我构建的代码中给出一个简单的例子:

int[] monTab = { 20, 56, 42, 5, 100, 123, 500 };    

public Form1()
{
    InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
    //Here I want to use the afficherTab(int[] x)
    //Code I thought :
    afficherTab(x);
}

public void afficherTab(int[] x)
{
    textBox1.Text = monTab[0].ToString(); 
    textBox2.Text = monTab[1].ToString(); 
    textBox3.Text = monTab[2].ToString();
    textBox4.Text = monTab[3].ToString();
    textBox5.Text = monTab[4].ToString(); 
    textBox6.Text = monTab[5].ToString(); 
    textBox7.Text = monTab[6].ToString();
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样非常简单,如果我在Form1_Load函数上使用它,我真的很想知道如何让我的文本框在这一点工作.

注意:到目前为止,它只显示了7个框的列表,我稍后会添加内容.我需要先了解如何继续这样做.

c# winforms

0
推荐指数
1
解决办法
65
查看次数

QComboBox激活(int)

我正在使用qt 5.2.我的连接功能的来电:

QObject::connect(ui->mycombobox, SIGNAL(activated(0)), ui->mypushbutton, SLOT(toggle()));
// When I select first element from mycombobox, mypushbutton must be disabled
Run Code Online (Sandbox Code Playgroud)

程序打印:

QObject::connect: No such signal QComboBox::activated(0) in <myfile>
Run Code Online (Sandbox Code Playgroud)

c++ qt

0
推荐指数
1
解决办法
3384
查看次数

SQL计数没有返回正确的计数

我有这个sql查询应该返回0的计数,但我想这是很糟糕的构建.

这是我执行的SQL代码

string cmdText = @"SELECT count(*) 
                   From Apointement 
                   WHERE emailClient=@emailClient AND 
                       trialdate=@trialdate AND 
                       TrailHour=trialhour";

SqlCommand cmd = new SqlCommand(cmdText, con);

cmd.Parameters.AddWithValue("@emailClient", Convert.ToString(Session["email"]));
cmd.Parameters.AddWithValue("@trialdate",dDateApt);
cmd.Parameters.AddWithValue("@trialhour", sHourApt);

if (con.State == ConnectionState.Closed)
{
    con.Open();
}

int nbrofRec = (int) cmd.ExecuteScalar();
if (nbrofRec >= 1)
Run Code Online (Sandbox Code Playgroud)

此查询返回1作为计数.

查询中的数据如下:

email     = s.brown@rv.com  
trialdate = 1/27/2014 12:00:00AM  
trialhour = 10:00
Run Code Online (Sandbox Code Playgroud)

数据库中的日期

email     = s.brown@rv.com  
trialdate = 1/27/2014 
trialhour = 12:00       <=== notice the only appointment is at 12:00 not at 10:00
Run Code Online (Sandbox Code Playgroud)

我找不出哪个元素是错的.

c# sql

0
推荐指数
1
解决办法
82
查看次数

当我的 ASP.Net 网站不允许执行我的 Web 托管服务的安全策略定义的某些操作时,我该怎么办?

我用 C# 编码的 asp.net 站点在本地系统上运行良好,但是当我通过 plesk 将文件上传到 httpdocs 文件夹时,出现以下错误:

Server Error in '/' Application.
________________________________________
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0246: The type or namespace name 'Xyz' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 1:  <%@ Application Language="C#" %>
Line 2:  <%@ …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

0
推荐指数
1
解决办法
5257
查看次数