norm? Got a question, I saw that NumPerPage starts with a default value of 6, yet some…
- User
norm?
Got a question, I saw that NumPerPage starts with a default value of 6, yet some menues change it to 5 as default. public int NumPerPage { get { return NumPerPage; } set { if (value > 6 || value <= 0) { NumPerPage = 5; return; }
NumPerPage = value; } }I did this, is it fine? (Do not blame for just a prop, not prop and field) xWidovV — Сегодня, в 22:00 huh 😐 Изображение Muinez — Сегодня, в 22:03 if (value is > 6 or <= 0) { value = 5; }
NumPerPage = value;xWidovV — Сегодня, в 22:04 Is it preffered to set value instead? Muinez — Сегодня, в 22:05 your code will call the setter again and do the check again, but why? xWidovV — Сегодня, в 22:07 I see, didn't really think about that. Thanks for elaborating instead of just thumbs down Muinez — Сегодня, в 22:14 Also, I think you should do value is > 5, not 6 xWidovV — Сегодня, в 22:14 That was elaborated in the first message https://github.com/roflmuffin/CounterStrikeSharp/blob/main/managed/CounterStrikeSharp.API/Modules/Menu/BaseMenu.cs#L77 GitHub CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Menu/Base... CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2 - roflmuffin/CounterStrikeSharp CounterStrikeSharp/managed/CounterStrikeSharp.API/Modules/Menu/Base... Muinez — Сегодня, в 22:18 then it might be a good idea to put this number in a separate property like public int MaxItemsPerPage => 5 in the IMenu xWidovV — Сегодня, в 22:20 And then use it per menu as a check or what? Muinez — Сегодня, в 22:25 did you move NumPerPage to IMenu? xWidovV — Сегодня, в 22:25 Yes Muinez — Сегодня, в 22:28 add MaxItemsPerPage to IMenu just like NumPerPage was before, and just use it in the condition
- Assistant