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

bookPractice: 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.

index.cs

index.cs

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(); } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 10

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Awesome!

Completion rate improved to 2.04

bookPractice: Constructors

Deslize para mostrar o menu

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.

index.cs

index.cs

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(); } }

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 10
some-alt