 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert.ToInt16 Method in C#
Convert a specified value to a 16-bit signed integer using the Convert.ToInt16 method in C#.
We have a double variable with a value initialized to it.
double doubleNum = 3.456;
Now, let us convert it to Int16 i.e. short.
short shortNum; shortNum = Convert.ToInt16(doubleNum);
Here is the complete example −
Example
using System;
public class Demo {
   public static void Main() {
      double doubleNum = 3.456;
      short shortNum;
      shortNum = Convert.ToInt16(doubleNum);
      Console.WriteLine("Converted {0} to {1}", doubleNum, shortNum);
   }
}
Output
Converted 3.456 to 3
Advertisements
                    