-1
이 코드는 스톱워치입니다.내 StopWatch 오류 (GetTimestamp)
인스턴스 참조로 액세스 할 수없는 이유는 무엇입니까?
오류 : 'System.Diagnostics.Stopwatch.GetTimestamp()'멤버는 인스턴스 참조로 액세스 할 수 없습니다. 대신 유형 이름으로 한정하십시오.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace Pocitadlo
{
public partial class Form1 : Form
{
public int minutys = 0, test = 0;
Thread sekund;
TimeSpan ts;
Stopwatch stopky = new Stopwatch();
public Form1()
{
InitializeComponent();
}
public void START_Click(object sender, EventArgs e)
{
sekund = new Thread(Sekund_pocet);
this.START.Visible = false;
this.STOP.Visible = true;
sekund.Start();
}
public void Sekund_pocet()
{
stopky.Start();
stopky.Stop();
ts = stopky.GetTimestamp();
string time = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds/10);
cas.BeginInvoke(new Action(() => cas.Text = Convert.ToString(time)));
}
private void STOP_Click(object sender, EventArgs e)
{
this.STOP.Visible = false;
this.START.Visible = true;
test = 1;
}
}
}
또한 코드를 영어로 작성하십시오. 모든 사람이 체코 어를 사용하지는 않습니다. – Filip
@Filip 대부분의 언어는 작성한 곳과 관계없이 대부분 영어로 동의합니다. 그 이유는 1. defacto 글로벌 언어 (영어)와 2입니다. 펑키 한 철자가 스며 들어 모든면에 있습니다. 예를 들어 컨벤션 색상 대 색상을 고수하는 것이 가장 좋습니다. C#은 영어로되어 있으므로 코드도 있어야합니다. – Clint