Karthikeya Boyini has Published 2383 Articles

How do you use ‘foreach’ loop for iterating over an array in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:41:04

353 Views

The for each loop similar to the for loop; however, the loop is executed for each element in an array or group. Therefore, the index does not exist in foreach loop.Let us see an example of Bubble Sort, wherein after sorting the elements, we will display the elements using the ... Read More

What is the Item property of SortedList class in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:38:52

54 Views

A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index.Gets and sets the value associated with a specific key in the SortedList.You can also use the Item property to add new ... Read More

How to set the style of the bottom border with JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:13:22

265 Views

To set the style of the bottom border, use the JavaScript borderBottomStyle property. It allows you to add a bottom border.ExampleYou can try to run the following code to set the style of the bottom border −           Demo Text         ... Read More

What is the purpose of ‘is’ operator in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:10:37

167 Views

The "is" operator in C# checks whether the run-time type of an object is compatible with a given type or not.The following is the syntax.expr is typeHere, expr is the expressiontype is the name of the typeThe following is an example showing the usage of is operator in C#.Exampleusing System; ... Read More

Const vs Static vs Readonly in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 11:03:56

903 Views

ConstConstant fields are the fields that cannot be modified. At the time of declaration, you need to assign a value to it.const int a = 5;StaticIf the static modifier is applied to a class then you cannot instantiate the class using the new keyword. You can use the static keyword ... Read More

Character constants vs String literals in C#

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 10:03:16

356 Views

Character constantsCharacter literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as '\t'), or a universal character (such as '\u02C0').Certain characters in C# are ... Read More

What is the IsFixedSize property of Hashtable class in C#?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 10:01:24

69 Views

Use the isFixedSize property of Hashtable class to get a value indicating whether the Hashtable has a fixed size.The following is an example showing how to work with IsFixedSize property.Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {   ... Read More

C# program to accept two integers and return the remainder

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:58:59

559 Views

Firstly, set the two numbers.int one = 250; int two = 200;Now pass those numbers to the following function.public int RemainderFunc(int val1, int val2) {    if (val2 == 0)    throw new Exception("Second number cannot be zero! Cannot divide by zero!");    if (val1 < val2)    throw new ... Read More

What will happen when ["demo"] is converted to Number in JavaScript?

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:58:50

61 Views

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert ["demo"] to Number in JavaScript −ExampleLive Demo           Convert ["demo"] to Number                var myVal = ["demo"];          document.write("Number: " + Number(myVal));          

C# program to generate secure random numbers

karthikeya Boyini

karthikeya Boyini

Updated on 23-Jun-2020 09:54:27

2K+ Views

For secure random numbers, use the RNGCryptoServiceProvider Class. It implements a cryptographic Random Number Generator.Using the same class, we have found some random values using the following −using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider()) {    byte[] val = new byte[6];    crypto.GetBytes(val);    randomvalue = BitConverter.ToInt32(val, 1); }To generate random ... Read More

Advertisements