I'm using umbraco.library:GetRandom to get a random number, but it doesn't quite behave like I expect it to. In my XSLT I've added a C# script that looks like this:
<msxml:script implements-prefix="random" language="C#"> <msxml:assembly name="umbraco"/> <msxml:using namespace="umbraco"/> <![CDATA[ public int GetRandom(int minValue, int maxValue) { return umbraco.library.GetRandom().Next(minValue, maxValue); } ]]> </msxml:script>
Now I expect it to return a value that is either 1 or 2 when I reload the page. The problem is that it returns only the number 1. If i alter the code to:
...it returns a number that is either 1 or 2. Is this a bug or does this mean that the maxValue is not actually the max value that it will return but rather the the max value that it won't return.
Can anyone else confirm this? Is it a bug or a feature or am I just using the method wrong?
Is there a bug in umbraco.library:GetRandom?
Hi!
I'm using umbraco.library:GetRandom to get a random number, but it doesn't quite behave like I expect it to. In my XSLT I've added a C# script that looks like this:
It comes from this thread where Thomas Höhler has a good random example.
As you can see it uses umbraco.library.GetRandom() to get a random number. In my XSLT-code I call it like this:
Now I expect it to return a value that is either 1 or 2 when I reload the page. The problem is that it returns only the number 1. If i alter the code to:
...it returns a number that is either 1 or 2. Is this a bug or does this mean that the maxValue is not actually the max value that it will return but rather the the max value that it won't return.
Can anyone else confirm this? Is it a bug or a feature or am I just using the method wrong?
Any pointers are greatly appreciated!
/Thomas Kahn
is working on a reply...