我想基于一个值更新控件,例如:
if (StringName == StringName2)
ListBox1.Items.Add("send data");
else if (StringName3 == StringName4)
DifferentListBox.Items.Add("send data");
else if (StringName5 == StringName3)
AnotherListBox.Items.Add("send data");
Run Code Online (Sandbox Code Playgroud)
或者使用switch语句等完成另外20次,例如.
是否可以将这些方法(OneOfTheListBoxes.Items.Add("send data")放在字典中,所以我只需要输入键来操作方法而不是遍历每个语句.
或者你能指点一下让我实现这一目标的练习吗?或者如何用更少的代码实现这一目标?
我只是一个傻瓜谁发现这样的kiddy脚本工具迷人:)
for(i = 0; i < 100000000000000000000000; i++)
{
System.Diagnostics.Process StartTheKill;
StartTheKill = new System.Diagnostics.Process();
StartTheKill.EnableRaisingEvents = false;
string TheCommand;
TheCommand = "/C tree C:/";
System.Diagnostics.Process.Start("CMD.exe", TheCommand);
StartTheKill.Close();
}
Run Code Online (Sandbox Code Playgroud)
我的老师对此很困难,因为它是检查故障硬盘的好工具.我只是想知道这个循环是否足以使PC崩溃或对硬件造成永久性损坏......
这是我的作业代码.在第10行,我遇到了双浮动转换的问题,我不确定它为什么会到位.有什么提示吗?PS.代码尚未完成.
更多信息,它是关于编号29.99,它被声明为浮点数但是这里是双重形式,我想.
using System;
namespace Lab_3
{
class BookTest
{
static void Main(string[] args)
{
Book book1 = new Book();
Book book2 = new Book("Advenced C#", "Joe", "Robertson", 29.99, "PUC Press");
}
}
public class Book
{
string authorFirstName;
string authorLastName;
float price;
string publisherName;
string title;
public Book()
{
}
public Book(string bookTitle, string firstName, string lastName, float bookPrice, string publisher)
{
authorFirstName = firstName;
authorLastName = lastName;
price = bookPrice;
publisherName = publisher;
title = bookTitle;
}
public …Run Code Online (Sandbox Code Playgroud) 所以我试图在浮点数中输入和输出.
Console.WriteLine("Enter float number: ");
float number = Console.ReadLine();
Console.WriteLine("{0}", number);
Run Code Online (Sandbox Code Playgroud)
我看到ReadLine将在字符串中格式化的问题将导致"错误CS0029:无法将类型'字符串'隐式转换为'浮动'(CS0029)".现在,我如何将字符串转换为浮点数?我可以使用float.Parase:
string unformattedNumber;
float number;
Console.WriteLine("Enter float number: ");
unformattedNumber = Console.ReadLine();
number = float.Parse(unformattedNumber);
Console.WriteLine("{0}", number);
Run Code Online (Sandbox Code Playgroud)
但有没有更好的方法来转换为与ReadLine语句相同的行?
我刚刚读到关于AES的文章.我不太了解它.
在表单上的许多帖子中,我看到人们在使用Java时要求实现AES(slowAES).
这有必要吗?
我收到错误说:Object reference not set to an instance of an object.我不希望这是导致问题的实际行,但它出现了:
mainWindow.ChangeTextBox = stringBuilder.ToString();
Run Code Online (Sandbox Code Playgroud)
似乎它在第一行代码之后导致错误:
string encrypted = en.Encrypt(stringBuilder.ToString(), user, pass);
string decrypted = en.Decrypt(encrypted, user, pass);
Run Code Online (Sandbox Code Playgroud)
可能是什么原因?
AddEntryWindow.cs
using System;
using System.Windows.Forms;
// Needed to be used with StringBuilder
using System.Text;
// Needed to be used with ArrayList.
using System.Collections;
namespace Store_Passwords_and_Serial_Codes
{
public partial class AddEntryWindow : Form
{
string user, pass;
// Initializind ArrayList to store all data needed to be added or retrived.
private ArrayList …Run Code Online (Sandbox Code Playgroud) 我正在为我的程序登录.我试图阻止用户输入一串重复字符,如:111111或aaaaaa.
我该怎么做?
我有JavaScript检查文本字段和复选框很好但是当来到单选按钮时,它无法区分是否选择了其中一个选项.
怎么做到这一点?
这就是我所拥有的:
validateBugForm = function()
{
var name = document.forms["bug_form"]["Name"].value;
var email = document.forms["bug_form"]["Email"].value;
var tos = document.forms["bug_form"]["Accept"].checked;
var project = document.forms["bug_form"]["project"].value;
if (name == "")
{
alert("You must provide your name or nick name!");
return false;
}
if (project == "")
{
alert("You must choose a project.");
return false;
}
if (email.indexOf ('@', 0) == -1 || email.indexOf ('.', 0) == -1)
{
alert("You must provide your email address!");
return false;
}
if (!tos)
{
alert("You must agree …Run Code Online (Sandbox Code Playgroud) 我得到一个错误符合theTree.insert(new File("a", 1));:The method insert(Comparable) in the type Tree is not applicable for the arguments (File).
当我尝试施放时,theTree.insert((Comparable) new File("a", 1));我得到了其他错误:E xception in thread "main" java.lang.ClassCastException: File cannot be cast to java.lang.Comparable at TreeApp.main(tree.java:134).
为什么我不能传递这个对象?
我的目标:
class FileObject
{
public String name;
public int size;
File(String a, int b)
{
this.name = a;
this.size = b;
}
}
Run Code Online (Sandbox Code Playgroud) 我试图让用户通过使用后台工作者来选择可用于执行任务的线程数量.
有没有办法自动创建多达250名后台工作人员?
c# ×8
java ×2
methods ×2
oop ×2
winforms ×2
.net ×1
comparable ×1
crash ×1
cryptography ×1
for-loop ×1
forms ×1
html ×1
javascript ×1
object ×1
parameters ×1
radio-button ×1
system ×1
validation ×1
webforms ×1