Array Rank Property of Array Class in C#

karthikeya Boyini
Updated on 20-Jun-2020 12:50:42

327 Views

Let us see an example to find the number of dimensions of an array, using the Rank property.arr.RankHere, arr is our array −int[, ] arr = new int[5, 5];If you want to get the rows and columns the array has, then use the GetLength property −arr.GetLength(0); arr.GetLength(1);The following is the complete code −Example Live Demousing System; class Program {    static void Main() {       int[, ] arr = new int[4, 5];       Console.WriteLine(arr.GetLength(0));       Console.WriteLine(arr.GetLength(1));       Console.WriteLine("Upper Bound: {0}", arr.GetUpperBound(0).ToString());       Console.WriteLine("Lower Bound: {0}", arr.GetLowerBound(0).ToString());     ... Read More

Prefix on String Literals in C#

Chandu yadav
Updated on 20-Jun-2020 12:50:07

797 Views

The @prefix states hat you don't need to escape special characters in the string following to the symbol.The following statement@"D:ew"is equal to:"D:ew"The @ prefix is also used if you want to have large strings and want it to be displayed across multiple lines. The following is an example showing multi-line string −Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {          string str = @"Welcome User,          Kindly wait for the image to          load";          Console.WriteLine(str);       }    } }OutputWelcome User, Kindly wait for the image to load

Use RemoveAt in C# ArrayList

George John
Updated on 20-Jun-2020 12:47:41

503 Views

The RemoveAt method in C# is used to remove an element in a list at a position you set.Firstly, set elements in the list −var subjects = new List(); subjects.Add("Physics"); subjects.Add("Chemistry"); subjects.Add("Biology"); subjects.Add("Science");To remove an element, set the index from where you want to eliminate the element. The following is to remove element from the 3rd position −subjects.RemoveAt(2);Let us see the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(string[] args){       var subjects = new List();       subjects.Add("Physics");       subjects.Add("Chemistry");       subjects.Add("Biology");   ... Read More

What is the Default Constructor in C#

Samual Sam
Updated on 20-Jun-2020 12:46:36

316 Views

A class constructor is a special member function of a class that is executed whenever we create new objects of that class. A default constructor does not have any parameter.The following is an example showing how to work with default constructor in C# −Example Live Demousing System; namespace LineApplication {    class Line {       private double length; // Length of a line       public Line(double len) { //Parameterized constructor       Console.WriteLine("Object is being created, length = {0}", len);          length = len;       }     ... Read More

What are Class Instances in C#

Arjun Thakur
Updated on 20-Jun-2020 12:45:18

5K+ Views

Class instances are objects. Like any other object-oriented language, C# also has object and classes. Objest are real-world entities and instance of a class. Access the members of the class using an object.To access the class members, you use the dot (.) operator after the object name. The dot operator links the name of an object with the name of a member for example, Box Box1 = new Box();Above you can see Box1 is our object. We will use it to access the members −Box1.height = 7.0;You can also use it to call member functions −Box1.getVolume();The following is an example ... Read More

MySQL Function to Find First Non-NULL Value

Ayyan
Updated on 20-Jun-2020 12:02:11

266 Views

We can use MySQL COALESCE() function to get the first non-NULL value as output from a list of values. In other words, this function will check all the values until non-null value found. It can take one or more than one argument. It is having the following syntax:COALESCE(value1, value2, …, valueN)ExampleFollowing is an example to demonstrate it −mysql> Select COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL); +--------------------------------------------------+ | COALESCE(NULL, NULL, NULL, 'Ram', 'Aarav', NULL) | +--------------------------------------------------+ | Ram                                              | +--------------------------------------------------+ 1 row in set (0.00 sec)

What MySQL Returns for Empty Hexadecimal to Number Conversion

Rishi Raj
Updated on 20-Jun-2020 12:01:04

134 Views

As we know that an empty hexadecimal value is a zero-length binary string hence if 0 is added to it then the result would be 0. In other words, we can say that if we convert an empty hexadecimal value to a number then it produces 0. The following query will make it understand −mysql> SELECT X''+ 0; +--------+ | X''+ 0 | +--------+ | 0      | +--------+ 1 row in set (0.15 sec)

How MySQL Evaluates an Empty Hexadecimal Value

Arjun Thakur
Updated on 20-Jun-2020 11:58:42

279 Views

Actually, MySQL evaluates an empty hexadecimal value to a zero-length binary string. It can be demonstrated as follows −mysql> Select CHARSET(X''); +--------------+ | CHARSET(X'') | +--------------+ | binary       | +--------------+ 1 row in set (0.00 sec)The above result set shows that the empty hexadecimal value is a binary string. And the result set below shows that it is of length 0.mysql> Select LENGTH(X''); +-------------+ | LENGTH(X'') | +-------------+ | 0           | +-------------+ 1 row in set (0.00 sec)

MySQL UNHEX Function with Non-Hexadecimal Argument

Alankritha Ammu
Updated on 20-Jun-2020 11:58:11

216 Views

MySQL returns NULL if we provide any non-hexadecimal number as an argument to UNHEX() function. Following example will demonstrate it.Examplemysql> Select UNHEX('ANK96598'); +-------------------+ | UNHEX('ANK96598') | +-------------------+ | NULL              | +-------------------+ 1 row in set (0.00 sec)As we know that the valid hexadecimal digits are between ‘0…9’, ‘A…F’ or ‘a…f’ hence the above query returns NULL.

What are the Comments in C#

Arjun Thakur
Updated on 20-Jun-2020 11:57:09

192 Views

Comments are used for explaining code. Compilers ignore the comment entries. The multiline comments in C# programs start with /* and terminates with the characters */ as shown below.Multi-line comments/* The following is a mult-line comment In C# /*The /*...*/ is ignored by the compiler and it is put to add comments in the program.Single line comments// variable int a = 10;The following is a sample C# program showing how to add single-line as well as multi-line comments −Example Live Demousing System; namespace Demo {    class Program {       static void Main(string[] args) {       ... Read More

Advertisements