Ankith Reddy has Published 1070 Articles

How to use the directory class in C#?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 12:33:42

252 Views

The Directory class in C# is used to manipulate the directory structure. It has methods to create, move, remove directories.The following are some of the methods of the Directory class.Sr.No.Method & Description1CreateDirectory(String)Creates all directories and subdirectories in the specified path2Delete(String)Deletes an empty directory3Exists(String)Whether the given path refers to an existing ... Read More

What is the best JavaScript code to create an img element?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 12:07:26

116 Views

Try any of the following for the width of the image you want to create −myImg.setAttribute('width', '5px');OrmyImg.width = '5';OrmyImg.style.width = '5px';You can also try the following code to add the width and height to the background image −var myImg = new Image(5, 5); myImg.src = 'http://www.example.com';Read More

How do you sort an array in C# in ascending order?

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 11:43:34

9K+ Views

Firstly, set the unsorted array.int[] list = {98, 23, 97, 36, 77};Sort the array using the Sort() method.Array.Sort(list);You can try to run the following code to to sort an array in ascending order.Example Live Demousing System; namespace Demo {    public class MyApplication {       public static void Main(string[] ... Read More

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

Ankith Reddy

Ankith Reddy

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

358 Views

Protected access specifier allows a child class to access the member variables and member functions of its base class. This way it helps in implementing inheritance. We will discuss this in more details in the inheritance chapter.The following is an example showing we have set an protected member variable in ... Read More

C# program to find maximum and minimum element in an array

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 11:35:29

6K+ Views

Set the minimum and maximum element to the first element so that you can compare all the elements.For maximum.if(arr[i]>max) {    max = arr[i]; }For minimum.if(arr[i]

Exception Propagation in C#

Ankith Reddy

Ankith Reddy

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

698 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

100 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

C# Interface Types

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 09:52:08

3K+ Views

Interfaces define properties, methods, and events, which are the members of the interface.Interfaces contain only the declaration of the members.Some of the interface types in C# include.IEnumerable − Base interface for all generic collections.IList − A generic interface implemented by the arrays and the list type.IDictionary − A dictionary collection.IEnumerable ... 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

335 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

2K+ 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

Advertisements