对于初学者练习,我试图创建一个简单的循环,它接受来自用户的单个字符,将该字符打印到控制台并继续这样做,直到用户输入“R”。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleLoop
{
class Program
{
static void Main(string[] args)
{
char cplayerSelection = 'R';
while(cplayerSelection == 'R')
{
Console.WriteLine("Enter R, P, or S:");
cplayerSelection = (char)Console.Read();
Console.WriteLine(cplayerSelection);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
无论用户输入什么,它只会循环一次结束然后退出。我需要更改什么才能继续循环?
我有一个填写父表格的小组.
我使用Timer来捕获屏幕,
并将屏幕截图设置为Panel的背景图像.
然而,它会遇到疯狂的闪烁.我该怎么做才能解决它?
//Part of code
public partial class Form1 : Form
{
DxScreenCapture sc = new DxScreenCapture();
public Form1()
{
InitializeComponent();
panelMain.BackgroundImageLayout = ImageLayout.Zoom;
}
private void Form1_Load(object sender, EventArgs e)
{
}
void RefreshScreen()
{
Surface s = sc.CaptureScreen();
DataStream ds = Surface.ToStream(s, ImageFileFormat.Bmp);
panelMain.BackgroundImage = Image.FromStream(ds);
s.Dispose();
}
private void timer1_Tick(object sender, EventArgs e)
{
RefreshScreen();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个拓扑问题.我尝试解释工作流程...我有一个源每2分钟发出~500k元组,这些元组必须由一个喷口读取,并像一个对象一样繁琐处理(我认为是三叉戟中的批处理).之后,一个bolt/function /还有什么?...必须附加一个时间戳并将元组保存到Redis中.
我尝试使用一个函数实现Trident拓扑,该函数使用Jedis对象(Redis库for Java)将所有元组保存到Redis中,但是当我部署时,我会在此对象上收到NotSerializable异常.
我的问题是.如何实现一个在Redis上写这批元组的函数?在网上阅读我找不到任何从函数写入Redis的示例或在Trident中使用State对象的任何示例(可能我必须使用它...)
我的简单拓扑:
TridentTopology topology = new TridentTopology();
topology.newStream("myStream", new mySpout()).each(new Fields("field1", "field2"), new myFunction("redis_ip", "6379"));
Run Code Online (Sandbox Code Playgroud)
提前致谢
很抱歉打扰您,但是C#Winforms出现了问题,因为我一直在寻找相同的问题,所以我找到了一些解决方案,但它们对我不起作用。好,我有一个包含对象的绑定列表
BindingList<objects.usuario> usuarios = new BindingList<objects.usuario>();
Run Code Online (Sandbox Code Playgroud)
这些对象有一些公共字符串和int变量,一个字符串和一个int是我需要的变量。
public string dataNombreCompleto;
public int dataIdUsuario;
Run Code Online (Sandbox Code Playgroud)
因此,一旦列表“ usuarios”中包含一些对象,我就可以执行此操作
cbAdministrativos.DisplayMember = "dataNombre";
cbAdministrativos.ValueMember = "dataIdUsuario";
cbAdministrativos.DataSource = usuarios;
Run Code Online (Sandbox Code Playgroud)
事实是,它不起作用,组合框(cbAdministrativos)仍显示该对象。
当我通过调试器时,在断点之后,组合框会随着代码的进行设置显示成员,值成员和数据源,但是,在下一条指令(方法的结尾)中,我意识到显示成员神奇地,改为字符串“ dataNombre”。
任何的想法?
在此先感谢您,并为英语不好对不起。
对不起,谢谢大家!在绝望中,我尝试了对象中的不同字段,但我没有意识到我为问题中的示例代码留下了“ dataNombre”而不是“ dataNombreCompleto”,这是正确的,那是我原始代码中的原始DisplayMember ,但是问题仍然存在:(
对我正在编写的系统的要求意味着我需要确定可能使用多种不同压缩/存档技术中的任何一种创建的文件/包的内容 - zip,gzip,rar,tar.这些文件将位于可以运行Windows或Unix/Linux的任何变体的远程系统上,并且可以使用任何压缩/存档技术创建文件(我将建立一个可管理的列表来支持).
System.IO.Packaging处理什么格式 - 只是拉链?
第三方图书馆?这不是我的首选 - 我需要在未来支持这个系统.
任何指导和建议将非常感谢.
要通过用户在C#中单击鼠标来提高绘制多点线的性能,我需要使线无效而不是矩形.有没有办法做到这一点?
panel1.Invalidate();
Run Code Online (Sandbox Code Playgroud) 我有一个播放声音的程序,但是如果我在另一台计算机上运行它,它说找不到该文件,我该如何将文件附加到 exe 上,这样当有人播放 exe 时,它仍然可以播放?
我正在使用这样的代码来加密文件.
FileStream fsInput = new FileStream(ifile_path,
FileMode.Open,
FileAccess.Read);
FileStream fsEncrypted = new FileStream(ofile_path,
FileMode.Create,
FileAccess.Write);
AesCryptoServiceProvider AES = new AesCryptoServiceProvider();
AES.Mode = CipherMode.CBC;
AES.KeySize = 256;
iv = AES.IV;
AES.Key = key;
ICryptoTransform aesencrypt = AES.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fsEncrypted,
aesencrypt,
CryptoStreamMode.Write);
byte[] bytearrayinput = new byte[fsInput.Length];
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Close();
fsInput.Close();
fsEncrypted.Close();
Run Code Online (Sandbox Code Playgroud)
但是,虽然此代码成功加密.txt和.xml文件,但它不适用于其他文件类型,如.docx或图像文件格式.我可以对代码进行哪些更改以将功能扩展到所有此类文件类型?
此代码有效:
class Person{
public Person p;
public string name;
private int age;
}
class Solution {
static void Main(String[] args) {
Person z = new Person () { name = "Stacl"};
Console.WriteLine (z.name);
Person a = new Person ();
Console.WriteLine (a.name);
}
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
class Person{
public Person p = new Person (){name = "Inside",age = 45}; // add 'new'
public string name;
private int age;
}
class Solution {
static void Main(String[] args) {
Person z = new Person …Run Code Online (Sandbox Code Playgroud) c# ×9
aes ×1
apache-storm ×1
combobox ×1
compression ×1
datetime ×1
embed ×1
encryption ×1
exe ×1
file ×1
flicker ×1
instance ×1
invalidation ×1
line ×1
oop ×1
panel ×1
redis ×1
refresh ×1
tar ×1
trident ×1
while-loop ×1
winforms ×1
zip ×1