小编Dav*_*wer的帖子

将值传递给C类的问题#

时间是我试图将值传递给的类.(txtHour.Text,txtMin.Text)是值.我只是想将值传递给参数化构造函数.而且我不完全确定它的语法是什么.

Time time1;
time1 = (txtHour.Text, txtMin.Text);
Run Code Online (Sandbox Code Playgroud)

**该方法似乎有效,除了我传入int值并且Text框的值被认为是字符串.当我解析它们时,它说它传递值不是正确的格式.

c#

0
推荐指数
2
解决办法
106
查看次数

返回成员函数显示字符串?C#

所以使用这个成员函数,我想"调用基类displayTime方法,然后将时区添加到输出消息"

 public string DisplayTime()
        {
            //return base.displayTime();
            return "okay";
        }//end of DisplayTime
Run Code Online (Sandbox Code Playgroud)

基类:

public void displayTime()
        {
            DateTime time = DateTime.Now; // Use current time
            string format = "MMM ddd d HH:mm yyyy"; // Use this format
            MessageBox.Show(time.ToString(format)); // Write to console

        }//end of displayTime
Run Code Online (Sandbox Code Playgroud)

可悲的是,我的第一个DisplayTime设置不正确,因为我不完全确定如何设置它.当谈到"return(""+ base.displayTime());"时,我尝试过不同的conbomations." 等等,这是行不通的.我不知道从哪里开始.

c#

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

C#"不包含带'1'参数的构造函数"

我之前发布过类似的内容并且它有所帮助,但之后我遇到了问题,无法做任何事情.所以我回来了!

Time time1;
private void btnNewTime_Click(object sender, EventArgs e)
        {
            Time time1 = new Time(Convert.ToInt32(txtHour.Text.Trim(), Convert.ToInt32(txtMin.Text)));


        }
Run Code Online (Sandbox Code Playgroud)

并在时间类:

        public Time()
        {
            hour = 12;
            minute = 00;
        }//end of Time

        public Time(int Hour, int Minute)
        {
            hour = Hour;
            minute = Minute;
        }//end of Time
Run Code Online (Sandbox Code Playgroud)

它假设进入参数化构造函数(第二个)但我得到错误:

"不包含带'1'参数的构造函数"

c#

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

获取当前时间然后递增它?

当前项目:使用两个类在C#中创建时间程序Time和ExtendedTime Time只是正常时间,而ExtendedTime具有时区.

当你启动程序时,我需要单击一个按钮并获取当前时间,但有一个选项可以更改时区.这反过来又改变了时间,并且还可以选择将时间增加这么多小时或几分钟.

目前,这是我的Time类中的displayTime方法:

public virtual string displayTime()
{
    DateTime time = DateTime.Now; // Use current time
    string format = "MMM ddd d HH:mm yyyy"; // Use this format
    MessageBox.Show(time.ToString(format)); // Write to console

    return time.ToString(format);
}//end of displayTime
Run Code Online (Sandbox Code Playgroud)

哪个也不错,除非我每次都称之为无关紧要因为它总会告诉我当前的时间 DateTime.Now

我不完全确定如何解决这个问题.我确信我可以做一次性交易,但不确定语法.

c# winforms

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

"// TODO实现了一个完整的类头"

"// TODO实现了一个完整的类头",用于我的C#类的最终项目,这是该项目的TODO之一.我不完全确定这意味着什么.

包含它的程序的顶部如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//TODO implement a complete class header

namespace Payroll
{


 [Serializable]


    public abstract class Employee:IPayable
    {
        #region "Variable Declarations"

        //create an enumeration that keeps track of the type
        public enum Type
        {
            Hourly = 1,
            Salary = 2,
            Contract = 3,
            None = 4
        };
Run Code Online (Sandbox Code Playgroud)

c# header

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

什么是并行运行Ruby脚本的正确方法?

目前我有以下代码在ruby脚本中运行一些ruby脚本:

def run(base_directory, run_count)
  working_directory = base_directory.gsub("\n","")
  for i in 1..run_count
    system("ruby " + working_directory + i.to_s + "\\" + "main.rb " +   working_directory + i.to_s + "\\")
  end
end
Run Code Online (Sandbox Code Playgroud)

但是,这会按顺序运行脚本,但我需要它们并行运行.我有10个脚本要运行,我想一次运行5个脚本,直到我达到需要运行的脚本数量.有没有一种简单的方法来实现这一目标?

ruby automation ruby-on-rails

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

标签 统计

c# ×5

automation ×1

header ×1

ruby ×1

ruby-on-rails ×1

winforms ×1