How to implement this primary constructor in a derived class if its base class has a constructor parameters? I tried this code but it doesn't work: public class Animal(string name, int age) { public string Name { get; } = name; public int Age { get; } = age; } public class Dog(string name, int age, string breed) : base(name, age) { public string Breed { get; } = breed; } Edit (this is now the new way): public class Animal(string name, int age) { public string Name { get; } = name; public int Age { get; } = age; } public class Dog(string name, int age, string breed) : Animal(name, age) { public string Breed { get; } = breed; } thanks this is great!
What’s the difference between public string First { get; } = firstname; public string First => firstname; public string First { get => firstname; } I know the result might be the same but I can’t see the difference 😢
The first one sets a default value for the First property. The second one is a computed property, so it won't be stored in the object, it's calculated whenever we read the property. The last one I guess is similar to the first one
in C# all functions are technically methods since you write your code in the Main() method even tho it's not shown when you start a new console App. So just call the methods functions in your head, it's exactly the same thing
@@maneshwam So what? Originaly Kotlin was inpired by C# and other languages. Some features was copied directly from C# . Here is the text from their oficial documentation in kotlin org / introduction : "Kotlin took inspiration from many programming languages, including (but not limited to) Java, Scala, C# and Groovy. ". You can go to Kotlin docs intrudaction and read this by yourself. So creator of Kotlin by himself says that Kotlin was inpired by C# and you says "NOPE" lol
These two men teach me a lot
@dotnet team please continue this series
What would be the NEXT best playlist to watch after finishing "C# for Beginners"? I definitely learned a lot from those two awesome instructors.
Hey, have you find one?
Glad i came to know about the primary constructors.tks
This series is W ❤🎉
Easier way to understand OOP than what I was taught.
Thank you!
Great tutorial video
How to implement this primary constructor in a derived class if its base class has a constructor parameters? I tried this code but it doesn't work:
public class Animal(string name, int age)
{
public string Name { get; } = name;
public int Age { get; } = age;
}
public class Dog(string name, int age, string breed) : base(name, age)
{
public string Breed { get; } = breed;
}
Edit (this is now the new way):
public class Animal(string name, int age)
{
public string Name { get; } = name;
public int Age { get; } = age;
}
public class Dog(string name, int age, string breed) : Animal(name, age)
{
public string Breed { get; } = breed;
}
thanks this is great!
What’s the difference between
public string First { get; } = firstname;
public string First => firstname;
public string First { get => firstname; }
I know the result might be the same but I can’t see the difference 😢
The first one sets a default value for the First property. The second one is a computed property, so it won't be stored in the object, it's calculated whenever we read the property. The last one I guess is similar to the first one
Congratulation 👋
Primary Constructors with polymorphism is yucky...
Episode 18 gets to OOP. Where the heck are functions?!
in C# all functions are technically methods since you write your code in the Main() method even tho it's not shown when you start a new console App. So just call the methods functions in your head, it's exactly the same thing
Looks like copy of the Kotlin language syntax.
🙂
Java + Kotlin = C#
No its Kotlin is copy of C#. C# was created in 2001 and Kotlin was created only in 2016 after 15 years of C# exising
@@antosha2224 Nope. C# introduced many new features in version 12, those features ex, primary constructor, look similar to Kotlin Lang.
@@maneshwam So what? Originaly Kotlin was inpired by C# and other languages. Some features was copied directly from C# . Here is the text from their oficial documentation in kotlin org / introduction : "Kotlin took inspiration from many programming languages, including (but not limited to) Java, Scala, C# and Groovy. ". You can go to Kotlin docs intrudaction and read this by yourself. So creator of Kotlin by himself says that Kotlin was inpired by C# and you says "NOPE" lol
@3:24 "This is a way to segre... segment" and @ 3:35 "For example, might be Fowler.People or Hanselman.People" ... freudian slip much? Muricans...