TGViewer
SpellSinger - разработчик игр на Unity SpellSinger - разработчик игр на Unity @spellsingergames · 548 subscribers
Post #52 549
В чём Java удобнее, чем C#?

В Java, при реализации интерфейса, я могу использовать дочерний тип в возвращаемом значении, а в C# не могу.

Java
class Fruit {
}
class Apple extends Fruit {
}
interface IBasket {
Fruit getFruit();
}
class Basket implements IBasket {
private Apple fruit;
@Override
public Apple getFruit() {
return fruit;
}
}


C#
class Fruit
{
}
class Apple : Fruit
{
}
interface IBasket
{
Fruit GetFruit();
}
class Basket: IBasket
{
private Apple fruit;
// Method 'GetFruit' cannot implement method from interface 'IBasket'. Return type should be 'Fruit'.
public Apple GetFruit()
{
return fruit;
}
}
  • 🤡 13
  • 👍 3
  • 🍓 3
  • 💩 1
More from @spellsingergames
  1. Oct 1, 2026Автор
  2. Aug 31, 2026Post #235
  3. Aug 25, 2026Прошли модерацию на Crazy Games. Basic Launch продлится до 15 сентября или пока не наберет…
  4. Aug 24, 2026А мы, тем временем, идём покорять #crazy_games Вчера ночью отправили билд на модерацию. Мо…
  5. Aug 24, 20262 недели нужно рекоммендеру Яндекс игр, чтобы как-то отреагировать на изменения метрик. AR…
  6. Aug 14, 2026Шестой эпизод подкаста ГЕЙМДЕВ ПОД ПИВОМ уже во вторник, в 22:30МСК! Хорошенечко отоспитес…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →