Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication3
- {
- class Osoba
- {
- private string Imię;
- private string Nazwisko;
- private int RokUrodzenia;
- public Osoba(string Im, string Naz, int RokUr)
- {
- Imię = Im;
- Nazwisko = Naz;
- RokUrodzenia = RokUr;
- }
- public void zapisz()
- {
- System.IO.StreamWriter sw = null;
- string nazwa = string.Format("{0}{1}.txt", Imię, Nazwisko);
- try
- {
- sw = new System.IO.StreamWriter(nazwa);
- sw.WriteLine("Imię: {0} Nazwisko: {1}", Imię, Nazwisko);
- sw.WriteLine("Rok Urodzenia: {0}", RokUrodzenia);
- }
- finally
- {
- if (sw != null) sw.Close();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Osoba m1 = new Osoba("Piotr", "Nowak", 2016);
- m1.zapisz();
- Osoba k1 = new Osoba("Ewa", "Kowalska", 2017);
- k1.zapisz();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement