- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Int16.MinValue Field in C# with Examples
The Int16.MinValue field in C# represents the smallest possible value of an Int16.
Syntax
Following is the syntax −
public const short MinValue = -32768;
Example
Let us now see an example to implement the Int16.MinValue field −
using System; public class Demo { public static void Main(){ short val1 = 23; short val2 = 0; Console.WriteLine("Value1 = "+val1); Console.WriteLine("Value2 = "+val2); Console.WriteLine("HashCode for value1 = "+val1.GetHashCode()); Console.WriteLine("HashCode for value2 = "+val2.GetHashCode()); Console.WriteLine("Are they equal? = "+(val1.Equals(val2))); TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("TypeCode for val1 = "+type1); Console.WriteLine("TypeCode for val2 = "+type2); Console.WriteLine("Maximum Value = "+ Int16.MaxValue); Console.WriteLine("Minimum Value = "+ Int16.MinValue); } }
Output
This will produce the following output −
Value1 = 23 Value2 = 0 HashCode for value1 = 1507351 HashCode for value2 = 0 Are they equal? = False TypeCode for val1 = Int16 TypeCode for val2 = Int16 Maximum Value = 32767 Minimum Value = -32768
Example
Let us now see another example to implement the Int16.MinValue field method −
using System; public class Demo { public static void Main(){ long[]val = {8998, -899898778, 878787878, -20}; short res; foreach(long a in val){ if(a >= Int16.MinValue && a <= Int16.MaxValue){ res = Convert.ToInt16(a); Console.WriteLine("Converted: "+res); } else { Console.WriteLine("Not Possible"); } } } }
Output
This will produce the following output −
Converted: 8998 Not Possible Not Possible Converted: -20
Advertisements