„Sznikák példakódok” változatai közötti eltérés

Kód javítása
a ConsoleColor nevű osztályt nem találja a VS-2017, helyette Color lett.
 
(10 közbenső módosítás, amit egy másik szerkesztő végzett, nincs mutatva)
10. sor: 10. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  class ThreadTestClass
  class ThreadTestClass
  {  
  {  
37. sor: 38. sor:
     }  
     }  
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
49. sor: 50. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  SqlConnection conn = null;  
  SqlConnection conn = null;  
  try  
  try  
  {  
  {  
     // Kapcsolódás azadatbázishoz  
     // Kapcsolódás azadatbázishoz  
     conn = new SqlConnection(@"Data Source=LAPTOP\SQLEXPRESS;InitialCatalog=Northwind;Integrated Security=True");  
     conn = new SqlConnection(@"Data Source=LAPTOP\SQLEXPRESS;
          InitialCatalog=Northwind;Integrated Security=True");  
     // A kapcsolat megnyitása  
     // A kapcsolat megnyitása  
     conn.Open();  
     conn.Open();  
83. sor: 86. sor:
       conn.Close();  
       conn.Close();  
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
95. sor: 98. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  public partial class MainForm : Form
  public partial class MainForm : Form
  {
  {
115. sor: 119. sor:
     }
     }
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
127. sor: 131. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  public partial class Form1 : Form
  public partial class Form1 : Form
  {
  {
     private Brush brush1;
     private Brush brush;
     private int grey = 200;
     private int grey = 200;
   
   
141. sor: 146. sor:
       base.OnKeyDown(e);
       base.OnKeyDown(e);
       if(e.KeyCode == Keys.R) {
       if(e.KeyCode == Keys.R) {
          grey -= 10;
           if(grey == 0) // ha elértük a színtartomány végét
           if(grey == 0) // ha elértük a színtartomány végét
             grey = 200;
             grey = 200;
          grey -= 10;
           Invalidate();
           Invalidate();
       }
       }
151. sor: 156. sor:
     {
     {
       base.OnPaint(e);
       base.OnPaint(e);
       using (brush1 = new SolidBrush(ConsoleColor.FromArgb(grey, grey, grey)))
       using (brush = new SolidBrush(Color.FromArgb(grey, grey, grey)))
       {
       {
           e.Graphics.FillRectrangle(brush1, 10, 20, 10+10, 20+10);
           e.Graphics.FillRectrangle(brush, 10, 20, 10, 10); // brush, x, y, width, height
       }
       }
     }
     }
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
169. sor: 174. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  public partial class Form1 : Form
  public partial class Form1 : Form
  {
  {
     DateTime lastClick;
     DateTime lastClick;
     String strDeltaTime;
     String strDeltaTime;
 
     public Form1()
     public Form1()
     {
     {
       InitializeComponent();
       InitializeComponent();
    }
      this.MouseClick += new MouseEventHandler(Form1_MouseClick);
     
    private void Form1_Load(object sender, EventArgs e)
       lastClick = null;
    {
       lastClick = DateTime.Now;
       strDeltaTime = "0";
       strDeltaTime = "0";
     }
     }
187. sor: 191. sor:
     private void Form1_MouseClick(object sender, MouseEventArgs e)
     private void Form1_MouseClick(object sender, MouseEventArgs e)
     {
     {
       TimeSpan deltaTime = DateTime.Now.Subtract(lastClick);
       if (lastClick = null)
      lastClick = DateTime.Now;
          lastClick = DateTime.Now;
      strDeltaTime = deltaTime.Seconds.ToString();
      else
      Invalidate(); // érvényteleníteni kell az ablak területet, hogy az új érték látszódjon
      {
          TimeSpan deltaTime = DateTime.Now.Subtract(lastClick);
          lastClick = DateTime.Now;
          strDeltaTime = deltaTime.Seconds.ToString();
          Invalidate(); // érvényteleníteni kell az ablak területet, hogy az új érték látszódjon
      }
     }
     }
   
   
199. sor: 208. sor:
     }
     }
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
206. sor: 215. sor:
| keretszín = black
| keretszín = black
| tartalom =
| tartalom =
Írjon programot, ami egy háttérszálban egy perc alatt aszámol 1-zől 60-ig és az aktuális értéket kiírja a konzolra
Írjon programot, ami egy háttérszálban egy perc alatt el számol 1-től 60-ig, és az aktuális értéket kiírja a konzolra.
{{Infobox-táblázat|
{{Infobox-táblázat|
{{Infobox-táblázatsor|A kód nyelve|C#}}
{{Infobox-táblázatsor|A kód nyelve|C#}}
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  public class Program
  public class Program
  {
  {
231. sor: 241. sor:
     }
     }
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
243. sor: 253. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  public class Singleton
  public class Singleton
  {
  {
261. sor: 272. sor:
     public void Print() {/* ... */}
     public void Print() {/* ... */}
  }
  }
</syntaxhighlight>


<syntaxhighlight lang="csharp">
  // Használata:
  // Használata:
  Singleton s1 = Singleton.Instance;
  Singleton s1 = Singleton.Instance;
267. sor: 280. sor:
  // Vagy:
  // Vagy:
  Singleton.Instance.Print();
  Singleton.Instance.Print();
 
</syntaxhighlight>


{{Infobox
{{Infobox
279. sor: 292. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  class SelectIntoDataSet{
  class SelectIntoDataSet{
     public static void Main(){
     public static void Main(){
309. sor: 323. sor:
     }
     }
  }
  }
 
</syntaxhighlight>


{{Infobox
{{Infobox
321. sor: 335. sor:
}}
}}
}}
}}
<syntaxhighlight lang="csharp">
  [AttributeUsage(AttributeTargets.All)]
  [AttributeUsage(AttributeTargets.All)]
  public class AuthorAttribute : System.Attribute
  public class AuthorAttribute : System.Attribute
339. sor: 354. sor:
     }
     }
  }
  }
</syntaxhighlight>


<syntaxhighlight lang="csharp">
  // Használata
  // Használata
  [Author("Béla Béla")]
  [Author("Béla Béla")]
346. sor: 363. sor:
  // ...
  // ...
  }
  }
</syntaxhighlight>


<syntaxhighlight lang="csharp">
  // Lekérdezés
  // Lekérdezés
  foreach( object attribute in something.GetCustomAttributes(true))
  foreach( object attribute in something.GetCustomAttributes(true))
352. sor: 371. sor:
     Console.WriteLine(attribute);
     Console.WriteLine(attribute);
  }
  }
</syntaxhighlight>


   
   
   
   


[[Kategória:Infoalap]]
[[Kategória:Mérnök_informatikus]]
A lap eredeti címe: „https://vik.wiki/Sznikák_példakódok