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;
- using System.Threading.Tasks;
- namespace ConsoleApplication2
- {
- class Program
- {
- static void Main(string[] args)
- {
- // instance
- Animal dog;
- dog = new Animal("Dogg");
- // initialisation
- Animal cat = new Animal("Kitten");
- cat.age = 5;
- cat.sayHello();
- Console.ReadKey();
- }
- class Animal
- {
- // variables
- string name;
- public int age;
- // constructor
- public Animal(string newName)
- {
- name = newName;
- }
- // functions
- public void sayHello() {
- Console.WriteLine(name + " is trying to say something!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement