Question by
Jacob_Anthony · Jun 11, 2017 at 11:06 AM ·
c#generics
how to rewrite script for combination which i have C#
i have this script for string combinations:
static IEnumerable<string> Combinations(List<string> characters, int length)
{
for (int i = 0; i < characters.Count; i++)
{
// only want 1 character, just return this one
if (length == 1)
yield return characters[i];
// want more than one character, return this one plus all combinations one shorter
// only use characters after the current one for the rest of the combinations
else
foreach (string next in Combinations(characters.GetRange(i + 1, characters.Count - (i + 1)), length - 1))
yield return characters[i] + next;
}
}
but i want to make it for gameobjects. So i tryied to make this static list or array and it didn't work too. I run out of ideas so maybe someone can help me?
Comment
Your answer
Follow this Question
Related Questions
How to add a Type to a Class in Javascript? 1 Answer
Checking for a class type issue 1 Answer
generics c# 1 Answer
List keeps losing items. 0 Answers
Can I implement generics to create objects that each work with a different class. 0 Answers