- Purpose : To understand the overflow situation
(In case of uint.MaxValue + 1)
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace overflow
7 {
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 // The maximum value of a is uint.MaxValue
13 uint a = uint.MaxValue;
14
15 Console.WriteLine(a);
16
17 // what if the 1 is added in a, what happened?
18 a = a + 1;
19
20 // of course, it will be overflowed!
21 Console.WriteLine(a);
22 }
23 }
24 }