Note that there are some explanatory texts on larger screens.

plurals
  1. POC# console reference use on windows form application project
    text
    copied!<p>I am Learning C#, but when i was trying to do a reference on a windows form application using a console code, the error The type or namespace name 'TidPunkt' could not be found (are you missing a using directive or an assembly reference?)</p> <p>Posting reference code below, then the Desinger.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class TidPunkt { int tim, min, sek; bool VisaSek = true; public void Sätt(int t, int m, int s) { if (t &gt;= 0 &amp;&amp; t &lt; 24 &amp;&amp; m &gt;= 0 &amp;&amp; m &lt; 60 &amp;&amp; s &gt;= 0 &amp;&amp; s &lt; 60) { tim = t; min = m; sek = s; } else Console.WriteLine("Felaktig tidpunkt"); } } public void SättVisaSek(bool visa) { VisaSek = visa; } public int AvLäsTim() { return tim; } public int AvläsMin() { return min; } public int AvläsSek() { return sek; } public void Ticka() { if (++sek == 60) { sek = 0; ++min; } if (min == 60) { min = 0; ++tim; } if (tim == 24) { tim = 0; } } public override string ToString() { string tid = tim + ":" + min; if (VisaSek) tid = tid + ":" + sek; return tid; } } } </code></pre> <p>Thats the reference code. posting the "Klockvisare.cs" code.</p> <pre><code>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; namespace WindowsFormsApplication1 { public partial class Klockvisare : Form { TidPunkt tp = new TidPunkt(); public Klockvisare() { InitializeComponent(); DateTime dt = DateTime.Now; tp.Sätt(dt.Hour, dt.Minute, dt.Second); a.Text = tp.ToString(); } private void timer1_Tick(object sender, EventArgs e) { tp.Ticka(); a.Text = tp.ToString(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload