Advertisement
Guest User

Untitled

a guest
May 25th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication3
  7. {
  8. class Osoba
  9. {
  10. private string Imię;
  11. private string Nazwisko;
  12. private int RokUrodzenia;
  13. public Osoba(string Im, string Naz, int RokUr)
  14. {
  15. Imię = Im;
  16. Nazwisko = Naz;
  17. RokUrodzenia = RokUr;
  18. }
  19. public void zapisz()
  20. {
  21. System.IO.StreamWriter sw = null;
  22. string nazwa = string.Format("{0}{1}.txt", Imię, Nazwisko);
  23. try
  24. {
  25. sw = new System.IO.StreamWriter(nazwa);
  26. sw.WriteLine("Imię: {0} Nazwisko: {1}", Imię, Nazwisko);
  27. sw.WriteLine("Rok Urodzenia: {0}", RokUrodzenia);
  28. }
  29. finally
  30. {
  31. if (sw != null) sw.Close();
  32. }
  33. }
  34.  
  35.  
  36.  
  37. class Program
  38. {
  39. static void Main(string[] args)
  40. {
  41. Osoba m1 = new Osoba("Piotr", "Nowak", 2016);
  42. m1.zapisz();
  43. Osoba k1 = new Osoba("Ewa", "Kowalska", 2017);
  44. k1.zapisz();
  45. }
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement