C# автоматически заполняет значения общих ограниченийC#

Место общения программистов C#
Ответить
Гость
 C# автоматически заполняет значения общих ограничений

Сообщение Гость »


I am writing generic unlockable elements for my game and I needed two similar classes with generic. I have used struct LevelBased where U : LevelUnlockable and expected C# to understand it without writing T value on LevelUnlockable.

When I am creating the type I am writing as LevelBased but since I will use int[] as T parameter, I thought it is okay to write like this LevelBased but if I do this, visual studio throws error.

Do I need to fill both T parameters, is there another way?

My current struct:

public struct LevelBased where U : LevelUnlockable { public U[] unlockables; public enum LevelBasedType { Clamp, Repeat } public LevelBasedType overshootBehaviour; } I have tried moving T parameter somewhere else but with no avail. I am expecting to write this LevelBased as LevelBased this.


Источник: https://stackoverflow.com/questions/781 ... nts-values
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»