C# : .NET

[".0s4*0|collections;datetime-format;collections",["F@eA","OEBEJAOIBEECBEJC","OBOOBYOBSTUUUUTTUUUUOPGDHDGDFOBBBOBCBWCSTTUUUUTTUUUU","wrt.",".NET","Array","Dictionary","List","String","2D","Async","Console","DataTable","Dates","DateTime","Enum","File","For","Foreach","Format","IEnumerable","If","IndexOf","Lambda","LINQ","Optimization","Parse","Path","Process","Property","Random","Regex","Replace","Sort","Split","Static","Substring","Switch","Tuple","While","Int.MaxValue."," An int has a maximum value it can represent. This value is found with int.MaxValue. The minimum value too can be determined with int.MinValue. Numeric types (int, uint, short and ushort) have specific max values. ","Int ","int","Values."," First, here we look at MSDN to see what Microsoft says. It states that MaxValue is a \"public const int\". With a bit of exploration, I found this information about the MaxValue and MinValue constants.","The fields"," are constant values and can be accessed anywhere with the composite name. By using these constants, you can avoid typing out 10-digit numbers in your programs. They are not equivalent to infinity. ","Constants ","const","Constant values:","\n\nshort.MaxValue: 32767\nshort.MinValue: -32768\nushort.MaxValue: 65535\nushort.MinValue: 0\nint.MaxValue: 2,147,483,647\nint.MinValue: -2,147,483,648\nuint.MaxValue: 4,294,967,295\nuint.MinValue: 0\nlong.MaxValue: 9,223,372,036,854,775,807\nlong.MinValue: -9,223,372,036,854,775,808","Example."," Here we clarify the logic in loops. One problem I have dealt with is keeping track of the lowest number found. You can use int.MaxValue to start the value really high, and then any lower number will be valid. ","Foreach ","foreach","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto","Beware edges."," When you start your variable at MaxValue, you will want to know the constraints in your program. If the MaxValue can occur, then you will need to be careful with the logic. But it would work correctly here. ","C# program that uses int.MaxValue","\n\nusing System;\n\nclass Program\n{\n static void Main()\n {\n int[] integerArray = new int[]\n {\n 10000,\n 600,\n 1,\n 5,\n 7,\n 3,\n 1492\n };","\n\n // This will track the lowest number found\n ","int lowestFound = ","int.MaxValue",";\n\n foreach (int i in integerArray)\n {","\n // By using int.MaxValue as the initial value,\n // this check will usually succeed.\n ","if (lowestFound > i)\n {\n lowestFound = i;\n Console.WriteLine(lowestFound);\n }\n }\n }\n}\n\n","Output","\n\n10000\n600\n1","Discussion."," In C# and Windows, there is no performance boost in using smaller data types in loops. Using ushort instead of int just creates unclear code. But prefer ushort, short and byte, for data structures\u2014this reduces memory use. ","Ushort ","ushort","Short ","short","Byte ","byte","Constants."," When you have other constants to define, follow Microsoft's example and declare them as \"public const int ValueName\". This has great performance, is standard, and clear for other developers. It works well with IntelliSense. ","Visual Studio ","vs","Also: ","Instead of using int.MaxValue and int.MinValue, consider nullable types, used with Nullable<int> or 'int?'.","Nullable Int ","nullable-int","Summary."," We saw values and examples for the max and min constants on number types in the C# language. I suggest that you avoid typing out numbers like -2,147,483,648 unless you have to\u2014and here you don't have to. ","Tip: ","Sometimes it is effective to start an int at int.MaxValue when you are looking for the lowest value in a loop.","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","3679700504","data-ad-format","link","br","ins","class","adsbygoogle","data-ad-client","ca-pub-4712093147740724","data-ad-slot","6227126509","data-ad-format","auto"],"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAAB5CAMAAAAwNFywAAAAYFBMVEX////Fvbzd3d03NjahnJuCf39dW1r19PQNDAzk5OT+7Orr6urw7+7/+vj/+Pb+6OX/8e7z4+D+5eL/9fL+39r+4t5tz/b//fym4vn//v605vqX3fmJ2Pj//v3D6/v/+/owObapAAAIJElEQVR4XuzTCw6DIBBFUXfBV7v/XVaJ6RTrC05eLYFyFzDJGYbJL37LpkJq6rplLSf3D/YCDv8DtgPcaflFD3B/+d7BAzzAsWGNy0Ng8aaalOKK4NgwFNcF2OkqgLVzK2jVATBgElW3SjvYHsDuvuppc7B4o/tRhJYBexLMx2N5cP3URHNWQ2ACK8W9kErISbx298ZmsXNeCRwg2FytCnXG5d5LYEN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pZ8A6/EyO4C99o3wYHVeyrMlIU5Daht4XARjGLPZFRqN3+P3teD/O5ULJXNTOplQmzfi2JEe7F6WcKhk3Is1N49+2vFjsSKZcmhWQGMFxro3hY3clawVPAYWNBz3I5wC8HXEK7CmmRcuq1Lj4tgHHJgohi5lDQHLi5+gvwm65TcO22Fl5FOv5ccS4tTqQmcbXVYjrNHtk9z8QIUL5v7XCdjKhaKzcwc5lXTIwM6godkXrRabrVcvpMcC2cFU/UF90LTk3Lt0iAZsMCF6e4UB5EK3nV+3RecJOc+GO9us61jrvTjxxY+CIr1sPvFOuBkdld/JR2wNeDuaFscnQ/uI/qjYLhbZdz9oZjzgXPLH7n+HeltWI+TJVx216Ef6fA/E/gJyP7lPifWJuUAAAAASUVORK5CYII=)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAG4AAACCAgMAAADasxWRAAAADFBMVEX/6Nn///+VlZX29va5ksB5AAAASElEQVR4AWPACZj/f0DmjkqOSjKtQgcLyJccZiEE9SOmP8mXHEaBMBoIo4EwGggryJccvvVKKAogTnJUclRyVHLklgmjkqOSAALWyrsxEHLDAAAAAElFTkSuQmCC)","url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAL4AAABBCAMAAABYbu5jAAAAMFBMVEX///+1wv+jqv9siv/p6//W3f8zZv9gb//19v9NK/8zAP999//S//8z//8zzP+z6P/0gInFAAABg0lEQVR4XtXXy1ICURAD0H7c96D+/9/KQqkhlEKD0iTrWZzKYtJXbou2s+jvn1Q55f2mfAMOb6Ec5D6+c/ObcvOdm98qN9+5+a1w842b3wo33/6Dv2H22g3zCL+PKF/uSKDsGL8pN9+5+U25+c7Nb5Wb74R8h+ki41eYLja+Qf1k/AL1k/HF4XIg4ytMFxl/X7/z8aF+Ov6A6bqR//FTnswXa2B96LmyPZtfoH4yvsDlwMaHy4GLj/Xz8RXqJ+PD5UDGh+ni448O08XEh+lSrtUVnC6qm+ey/krGx+li4+N0sfHh7Cfj43Sx8bF+Mj5OF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