How to create new type in c#? For example byte has range 0 to 255, but I need new type which would have 0 to 10 range.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Amazing that people want to close this as not a real question!
The answer is that C# does not have a type system that supports checking integer ranges at compile time, except for a few built-in cases: it stops you assigning larger-range numbers to smaller-range numbers. But the ranges for those numbers are pre-defined in the language specification.