George John has Published 1167 Articles

How to use the Main() method in C#?

George John

George John

Updated on 23-Jun-2020 12:41:09

615 Views

A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.The Main method states what the class does when executed and instantiates other objects and variables.The following ... Read More

How to sort an array in C#?

George John

George John

Updated on 23-Jun-2020 12:38:10

1K+ Views

The following is the integer array.int[] arr = { 99, 43, 86 };To sort, use the Sort() method.Array.Sort(arr);The following is the complete code displaying how to sort an array in C# using the Sort() method.Example Live Demousing System; class Demo {    static void Main() {       int[] arr ... Read More

What are abstract properties in C#?

George John

George John

Updated on 23-Jun-2020 12:22:10

643 Views

An implementation of the property accessors will not be provided by an abstract property declaration.Let us see how to learn how to work with abstract properties. Here we have an abstract class Shape with two derived classes: Square and Circle.Here, we have an abstract Area property.The following is the Circle ... Read More

How to find maximum between 2 numbers using C#?

George John

George John

Updated on 23-Jun-2020 12:12:53

1K+ Views

Firstly, declare and initialize two numbers.int num1 = 50; int num2 = 90;With that, use if-else to find the maximum number.if (num1 > num2) {    maxNum = num1; } else {    maxNum = num2; }Above, we have set the maximum value to the variable maxNum and printed it ... Read More

How to create nested while loop in C#?

George John

George John

Updated on 23-Jun-2020 12:06:18

269 Views

For a nested while loop, we have two while loops.The first loop checks for a condition and if the condition is true, it goes to the inner loop i.e. the nested loop.Loop 1while (a

Difference between Method and Function in C#

George John

George John

Updated on 23-Jun-2020 11:40:18

5K+ Views

Methods and Functions are the same in C#.However, Methods are used in C# and are functions that operate through a designated class. A method is a group of statements that together perform a task. Every C# program has at least one class with a method named Main.The following is a ... Read More

C# program to determine if a string has all unique characters

George John

George John

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

2K+ Views

Use the substring() method in C# to check each and every substring for unique characters. Loop it until the length of the string.If any one the substring matches another, then it would mean that the string do not have unique characters.You can try to run the following code to determine ... Read More

Delete nth element from headnode using C#

George John

George John

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

109 Views

Firstly, set a link list and add some elements.Demo list = new Demo(); list.Push(50); list.Push(100); list.Push(150);Now to delete nth element from headnode, pass what you want to delete. If you will set 1, then it will delete the head node.Exampleif (val == 1) {    head = head.Next;    return; ... Read More

DivideByZeroException Class in C#

George John

George John

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

633 Views

C# exceptions are represented by classes. The exception classes in C# are mainly directly or indirectly derived from the System.Exception class. Some of the exception classes derived from the System.Exception class are the System.ApplicationException and System.SystemException classes.System.DivideByZeroException is a class that handles errors generated from dividing a dividend with zero.Example Live ... Read More

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

George John

George John

Updated on 23-Jun-2020 10:05:00

69 Views

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

Advertisements