我有一个C#winform应用程序正在做很多计算.有一个"运行"按钮来触发该过程.我希望能够"重新触发或重新运行或重新提交"信息,而无需重新启动程序.问题是我有很多需要重置的变量.有没有办法取消(重置)所有参数?
private Double jtime, jendtime, jebegintime, javerage, .... on and on
Run Code Online (Sandbox Code Playgroud) 我有这个字符串MIL_A_OP=LI_AND=SSB12=JL45==DO=90==IT=KR002112
,我需要将它拆分为2,基于第一个"="
所以我需要它得到:
第一个字符串 MIL_A_OP
第二串: LI_AND=SSB12=JL45==DO=90==IT
这下面的代码是我的,但它给了我MIL_A_OP和LI_AND,我想念其余的
try
{
StreamReader file1 = new StreamReader(args[0]);
string line1;
while ((line1 = file1.ReadLine()) != null)
{
if (line1 != null && line1.Trim().Length > 0)//if line is not empty
{
int position_1 = line1.IndexOf('=');
string s_position_1 = line1.Substring(position_1, 1);
char[] c_position_1 = s_position_1.ToCharArray(0,1);
string[] line_split1 = line1.Split(c_position_1[0]);
Foo.f1.Add(line_split1[0], line_split1[1]);
}
}
file1.Close();
}
catch (Exception e)
{
Console.WriteLine("File " + args[0] + " could not be read");
Console.WriteLine(e.Message);
}
Run Code Online (Sandbox Code Playgroud) 我正在读一个文件,我想知道如何跳过具有Unicode NULL,U + 0000的行?我已尝试过以下所有内容,但都没有效果:
if($line)chomp($line)$line =~ s/\s*$//g;我想在循环中创建多个对象/实例.这该怎么做?
class lh
{
public string name;
public lh(string name)
{
this.name = name; ;
}
}
while((line = ps.ReadLine()) !=null)
{
lh a = new lh(line);
}
Run Code Online (Sandbox Code Playgroud)
很明显,我无法一遍又一遍地使用相同的名称(a)创建一个新对象
private static void print(StreamWriter sw, string mlog, bool screen)
{
DateTime ts = DateTime.Now;
sw.WriteLine(ts + " " + mlog);
if (screen == true)
{
Console.WriteLine(mlog);
}
}
Run Code Online (Sandbox Code Playgroud)
我会print (sw,"write here", false)打电话来.我有90%的机会使用假.如何使它成为默认为假的方式,当我打电话时,我没有必要做额外的类型?
我可以通过以下方式获得最新创建的内容; 但我希望用最新创建的最新版本创建最新版本
var directory = new DirectoryInfo("D:\\my_dir\\dir_1\\dir_2\\");
var smf_log_name = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
Run Code Online (Sandbox Code Playgroud) 我想创建一个通用的记录器类.这抱怨"值不能为null.参数名称:路径".初始化对象后,我得到了logname值但没有log.我哪里做错了?
class Logger
{
public static string log;
public Logger(string logname)
{
log = logname;
}
StreamWriter writer = new StreamWriter(log);
}
Run Code Online (Sandbox Code Playgroud) 计时器,电子邮件附件发送工作正常.但是文件删除失败."该进程无法访问文件x,因为它正由另一个进程使用"我不明白.谁在使用该文件?文件已发送并完成.删除是在发送电子邮件之后.为什么错误?
class Program
{
static void Main(string[] args)
{
Timer aTimer = new Timer(10000);
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Enabled = true;
Console.WriteLine("Press the Enter key to exit the program.");
Console.ReadLine();
}
private static void OnTimedEvent(object source, ElapsedEventArgs e )
{
Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime);
string[] DirList = Directory.GetFiles(@"C:\dir_a");
if (DirList.Length > 0)
{
foreach (string s in DirList)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("xx");
mail.From = new MailAddress("xx");
mail.To.Add("xx"); …Run Code Online (Sandbox Code Playgroud) 假设程序接收输入字符串"8*10+6/2"并且应该输出83,在这种情况下.如何处理运营商?
我可以将字符串切成单个字符串,然后检测它是数字还是运算符.如果是操作员我可以将其转换为int.但我不知道如何处理运算符,以便计算工作.
快速提问:如何获得6位数毫秒?限制是3.其他选择?建议?
DateTime dt = new DateTime(2008, 08, 08, 08, 10, 10, 100)
Run Code Online (Sandbox Code Playgroud) 哪一个更好?明智的表现和明智的最佳实践.为什么?
if ((process_checking == true) && (standard_output.Contains("0")))
{
}
else if ((process_checking == true) && (standard_output.Contains("1")))
{
}
Run Code Online (Sandbox Code Playgroud)
要么
if (process_checking==true)
{
if (standard_output.Contains("0"))
{
blah
}
else
//there is only 0 or 1 value
{
blah
}
}
Run Code Online (Sandbox Code Playgroud)