

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
- Related Questions & Answers
- How to Convert the TimeSeries using the series.asfreq() method?
- Convert Long into String using toString() method of Long class in java
- Is there any method to convert a Set to immutable in Java
- Convert an object to another type using map() method with Lambda in Java?
- Java Program to convert Double into String using toString() method of Double class
- How to convert a double value into a Java String using append method?
- How to convert a double value into a Java String using format method?
- What is the equivalent of MySQL TIME_TO_SEC() method in PHP to convert datetime to seconds?
- Is it possible to convert a number into other base forms using toString() method in JavaScript?
- Convert Class in C#
- Class method vs static method in Python
- Collections.replaceAll() method and List.replaceAll() method in Java
- convert list to array in java
- convert InputStream to ByteArray in java
- Convert string to bool in C#
- Convert Decimal to Binary in Java
Advertisements