V
V
Vitaly Rybchenko2015-11-12 18:28:47
C++ / C#
Vitaly Rybchenko, 2015-11-12 18:28:47

"Total 12 questionnaires" - replacement of the end of the word "questionnaires" depending on the number. Are there ready-made solutions?

Does anyone have a solution for this issue?
I think that if I write from scratch, then I will invent a wheel - I don’t want to)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ilya, 2015-11-12
@biovr

I use this solution:

/// <summary>
///     Склонение существительных после числительных.
/// </summary>
/// <param name="iNumber">Число</param>
/// <param name="aEndings">Массив слов или окончаний для чисел (1, 4, 5)</param>
/// <returns>Вовращает вариант окончания или слова для числительного</returns>
public static string GetNumEnding(long iNumber, string[] aEndings)
{
  string sEnding;
  iNumber = iNumber%100;
  if (iNumber >= 11 && iNumber <= 19)
  {
    sEnding = aEndings[2];
  }
  else
  {
    var i = iNumber%10;
    switch (i)
    {
      case (1):
        sEnding = aEndings[0];
        break;
      case (2):
      case (3):
      case (4):
        sEnding = aEndings[1];
        break;
      default:
        sEnding = aEndings[2];
        break;
    }
  }
  return sEnding;
}

Example:
GetNumEnding(notices.Count, new[] {"объявление", "объявления", "объявлений"})

H
heartdevil, 2015-11-12
@heartdevil

Hello.
Don't mess around with this. Better change to "Total profiles - 0/1/2/38/10/100". You're just wasting your time on this crap.

W
wkololo_4ever, 2015-11-12
@wkololo_4ever

At work we use morpher.ru at work , but as a dll it's paid. There is a free API.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question