.NET API, more appropriate parameter specification, e.g. System.Random.Next(Int32 to UInt32)

Daniel Domanski 20 Reputation points
2023-06-10T09:02:11.6333333+00:00

Hi,

I'm working with the .NET (C#) learning-modules and was instructed to have a look at the Random-class with its Next Method and the overloaded version with 1 parameter.

According to the parameter section the value has to be equals or higher than 0/zero. I already know about the UInt32 value type, which fits perfectly to the mentioned constraint.

Shouldn't it be changed from Int32 to UInt32 then?

Best Regards

Daniel

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,103 questions
{count} votes

Accepted answer
  1. David Lowndes 2,630 Reputation points MVP
    2023-06-10T10:27:43.39+00:00

    Some .NET languages may not support unsigned types, so .NET APIs shouldn't use them. See here.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Daniel Domanski 20 Reputation points
    2023-06-10T11:03:09.6266667+00:00

    If someone seeing this is searching for CLS-compliant alternatives for such data types.

    Types and type-member signatures, CLS-compliant alternatives

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.