×

C# Tutorial

Basics of .Net

C# Basics

C# Fundamentals

C# Operators

C# Loops

C# Type Conversions

C# Exception Handling

C# String Class

C# Arrays

C# List

C# Stack

C# Queue

C# Collections

C# Character Class

C# Class and Object

C# Namespaces

C# Delegates

C# Constructors

C# Inheritance

C# Operator Overloading

C# Structures

C# File Handling

C# Convert.ToInt32()

C# Int32 (int) Struct

C# DateTime Class

C# Uri Class

C# Database Connectivity

C# Windows

C# Other Topics

C# Q & A

C# Programs

C# Find O/P

C# short Keyword with Example

In this tutorial, we will learn about the short keyword in C# (with Example), what is short keyword, how to use it in C#? By IncludeHelp Last updated : April 04, 2023

C# short Keyword

In C#, short is a keyword which is used to declare a variable that can store a signed integer value between the range of -32,768 to 32,767. short keyword is an alias of System.Int16.

It occupies 2 bytes (16 bits) space in the memory.

Syntax

short variable_name = value;

Example of short keyword in C#

Here, we are declaring a short variable num, initializing it with the value 12345 and printing its value, type and size of a short type variable.

using System;
using System.Text;

namespace Test {
  class Program {
    static void Main(string[] args) {
      //variable declaration
      short num = 12345;

      //printing value
      Console.WriteLine("num: " + num);
      //printing type of variable
      Console.WriteLine("Type of num: " + num.GetType());
      //printing size
      Console.WriteLine("Size of a short variable: " + sizeof(short));
      //printing minimum & maximum value of short
      Console.WriteLine("Min value of short: " + short.MinValue);
      Console.WriteLine("Max value of short: " + short.MaxValue);

      //hit ENTER to exit
      Console.ReadLine();
    }
  }
}

Output

num: 12345
Type of num: System.Int16
Size of a short variable: 2
Min value of short: -32768
Max value of short: 32767

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.