Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Practice: Constructors | Introduction to Object-Oriented Programming (OOP)
C# Beyond Basics
course content

Kurssisisältö

C# Beyond Basics

C# Beyond Basics

1. Additional Structures & File Handling
2. Structs & Enumerators
3. Introduction to Object-Oriented Programming (OOP)
4. OOP Essentials
5. OOP Principles

book
Practice: Constructors

A simple class called Dog is given. Create a constructor which takes in the arguments name, breed, age, and initializes the fields from the values of arguments.

cs

index

copy
123456789101112131415161718192021222324
using System; class Dog { public string name; public string breed; public int age; // Write constructor code below this line // Write constructor code above this line public void bark() { Console.WriteLine("Woof!"); } } public class ConsoleApp { public static void Main(string[] args) { Dog dog = new Dog("Dobby", "Dobermann", 4); dog.bark(); } }

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 10
Pahoittelemme, että jotain meni pieleen. Mitä tapahtui?
some-alt