BitArray.RightShift() Method in C# with Examples Last Updated : 27 Mar, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report BitArray class manages a array of bit values, which are represented as Booleans, where true indicates bit is 1 and false indicates bit is 0. This class is contained in namespace, System.Collections. BitArray.RightShift(Int32) method is used to shift the bits of the bit array to the right by one position and adds zeros on the shifted position. Original BitArray object will be modified on performing the operation right shift. Syntax: public System.Collections.BitArray RightShift (int count); Parameter: count is an immutable value type that represents signed integers with values that range from negative 2,147,483,648 through positive 2,147,483,647. Return value : It returns Bit Array. Example 1: Suppose we have the bit array 10011 we want to shift it right by two positions. The final result is 00100. csharp // C# program to illustrate the // RightShift(Int32) Method using System; using System.Collections; class GeeksforGeeks { // Main Method public static void Main() { // Creating a BitArray of // size 5 named BitArr BitArray BitArr = new BitArray(5); // Initializing values in BitArr BitArr[0] = true; BitArr[1] = true; BitArr[2] = false; BitArr[3] = false; BitArr[4] = true; // function calling Display(BitArr.RightShift(2)); } // Displaying the result public static void Display(IEnumerable myList) { foreach(Object obj in myList) { Console.WriteLine(obj); } } } Output: False False True False False Example 2: Suppose we have the bit array 100011 we want to shift it right by three positions. The final result is 011000. csharp // C# program to illustrate the // RightShift(Int32) Method using System; using System.Collections; class GeeksforGeeks { // Main Method public static void Main() { // Creating a BitArray BitArray BitArr = new BitArray(6); // Initializing values in BitArr BitArr[0] = true; BitArr[1] = false; BitArr[2] = false; BitArr[3] = false; BitArr[4] = true; BitArr[5] = true; // function calling Display(BitArr.RightShift(3)); } // Displaying the result public static void Display(IEnumerable myList) { foreach(Object obj in myList) { Console.WriteLine(obj); } } } Output: False True True False False False Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.bitarray.rightshift?view=netcore-2.2 Comment More infoAdvertise with us Next Article Array.GetValue() Method in C# with Examples | Set â 4 A AmanAgarwal6 Follow Improve Article Tags : C# Similar Reads BitArray.LeftShift() Method in C# with Examples BitArray class manages a array of bit values, which are represented as Booleans, where true indicates bit is 1 and false indicates bit is 0. This class is contained in namespace, System.Collections. BitArray.LeftShift(Int32) method is used to shift the bits of the bit array to the left by one positi 2 min read Array.GetValue() Method in C# with Examples | Set â 2 Array.GetValue() Method in C# is used to gets the value of the specified element in the current Array. There are total 8 methods in the overload list of this method which are as follows: Array.GetValue(Int32, Int32) Array.GetValue(Int64, Int64) Array.GetValue(Int32) Array.GetValue(Int64) Array.GetVa 3 min read Array.GetValue() Method in C# with Examples | Set - 1 Array.GetValue() Method in C# is used to gets the value of the specified element in the current Array. There are total 8 methods in the overload list of this method which are as follows: Array.GetValue(Int32, Int32) Array.GetValue(Int64, Int64) Array.GetValue(Int32) Array.GetValue(Int64) Array.GetVa 4 min read Array.GetValue() Method in C# with Examples | Set â 4 Array.GetValue() Method in C# is used to gets the value of the specified element in the current Array. There are total 8 methods in the overload list of this method which are as follows: Array.GetValue(Int32, Int32)Array.GetValue(Int64, Int64)Array.GetValue(Int32)Array.GetValue(Int64)Array.GetValue( 5 min read Array.GetValue() Method in C# with Examples | Set â 3 Array.GetValue() Method in C# is used to gets the value of the specified element in the current Array. There are total 8 methods in the overload list of this method which are as follows: Array.GetValue(Int32, Int32)Array.GetValue(Int64, Int64)Array.GetValue(Int32)Array.GetValue(Int64)Array.GetValue( 5 min read Array.BinarySearch(Array, Object) Method with examples in C# This method is used to search a specific element in the entire one-dimensional sorted array by using the IComparable interface which is implemented by each element of the array and by the specified object. Syntax: public static int BinarySearch (Array array, object value); Parameters: array: It is t 4 min read Like