Ankith Reddy has Published 996 Articles

Exception Propagation in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 11:25:19

1K+ Views

Exception Propogation can be understood by how exception handling works in C#.In try, when an exception occurs the corresponding catch blocks are checked. This is done to see if they can catch the exception. If no matching exception is found, the exception is propagated to a higher-level try block. This ... Read More

Compute modulus division by a power-of-2-number in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 11:05:24

144 Views

We have taken the number as the following −uint a = 9; uint b = 8;Above, a is a divisor and b is dividend.To compute modulus division.Example Live Demousing System; class Demo {    static uint display( uint a, uint b) {       return ( a & (b-1) ); ... Read More

What is the scope of a public member variable of a class in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:40:38

451 Views

Public access specifier allows a class to expose its member variables and member functions to other functions and objects. Any public member can be accessed from outside the class.In the below example the variables length and width have been declared public. Now you can even access them outside the Main() ... Read More

Constructor Overloading in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:14:03

3K+ Views

When more than one constructor with the same name is defined in the same class, they are called overloaded, if the parameters are different for each constructor.Let us see an example to learn how to work with Constructor Overloading in C#.In the example, we have two subjects and a string ... Read More

C# Program to access tuple elements

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:09:46

336 Views

Create a tuple.var myTuple = Tuple.Create(1, 2.5M, "Amit", "100");Now to access tuple elements, use the properties.To access first element.myTuple.Item1To access second element.myTuple.Item2In the same way, for other elements, use the properties as shown below −Example Live Demousing System; public class Program {    public static void Main() {       ... Read More

C# Math.BigMul Method

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:07:03

206 Views

Use the Math.BigMul() method to find the product of two 32-bit numbers.The following are our two numbers.int one = 345272828; int two = 887685744;Now, get the product.long res; res = Math.BigMul(one, two);Example Live Demousing System; using System.Globalization; class Demo {    static void Main() {       int one = ... Read More

Convert.ToUInt64 Method in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:03:26

183 Views

Use the Convert.ToUInt64() method to convert a specified value to a 64-bit unsigned integer.The following is our char.char ch = 'a';Now, let’s convert it to a 64-bit unsigned integer.ulong res; res = Convert.ToUInt64(ch);Here is the complete example.Example Live Demousing System; public class Demo {    public static void Main() {   ... Read More

C# Program to find a key in Dictionary

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:02:10

317 Views

Firstly, set a Dictionary collection with elements.Dictionary d = new Dictionary() {    {1, "Applianes"},    {2, "Clothing"},    {3, "Toys"},    {4, "Footwear"},    {5, "Accessories"} };Now, let’s say you need to check whether key 5 exists or not. For that, use ContainsKey() method. It returns True if key ... Read More

Get Upperbound and Lowerbound of a three-dimensional array in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 08:56:32

2K+ Views

To get the Upperbound and Lowerbound, use the GetUpperBound() GetLowerBound() methods in C#, respectively.The parameter to be set under these methods is the dimensions i.e.Let’s say our 3D array is −int[, , ] arr = new int[2, 3, 4];For a three-dimensional arrays, dimension 0.arr.GetUpperBound(0) arr.GetLowerBound(0)For a three-dimensional arrays, dimension 1.arr.GetUpperBound(1) ... Read More

Implicit conversion from Byte to Decimal in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 08:44:39

430 Views

Byte represents an 8-bit unsigned integer.Implicit conversion of an 8-bit unsigned integer (Byte) to a Decimal is possible. Let us see how.Here’s our Byte value.byte val = 16;To implicitly convert, just assign the value as shown below −decimal dec; dec = val;Let us see the complete example.Example Live Demousing System; public ... Read More

Advertisements