Found 27759 Articles for Server Side Programming

C# program to sort an array in descending order

Samual Sam
Updated on 23-Jun-2020 11:33:39

3K+ Views

Initialize the array.int[] myArr = new int[5] {98, 76, 99, 32, 77};Compare the first element in the array with the next element to find the largest element, then the second largest, etc.if(myArr[i] < myArr[j]) {    temp = myArr[i];    myArr[i] = myArr[j];    myArr[j] = temp; }Above, i and j are initially set to.i=0; j=i+1;Try to run the following code to sort an array in descending order.Example Live Demousing System; public class Demo {    public static void Main() {       int[] myArr = new int[5] {98, 76, 99, 32, 77};       int i, j, temp;       Console.Write("Elements: ");       for(i=0;i

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

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 if a string has all unique characters.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class Demo {    public bool CheckUnique(string str) {       string one = "";       string two = "";       for (int i = 0; i ... Read More

Difference between C# and .Net

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

4K+ Views

C# is a programming language and .NET is a framework. .NET has Common Language Runtime (CLR), which is a virtual component of .NET framework. .NET not only has C#, but through it, you can work with VB, F#, etc. C# is a part of .NET and has the following features − Boolean Conditions Automatic Garbage Collection Standard Library Assembly Versioning Properties and Events Delegates and Events Management Easy-to-use Generics Indexers Conditional Compilation Simple Multithreading LINQ and Lambda Expressions Integration with Windows

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

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

5K+ 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]

Explain C# Grouping Constructs in regular expression

Samual Sam
Updated on 30-Jul-2019 22:30:23

191 Views

There are various categories of characters, operators, and constructs that lets you to define regular expressions. One of them is Grouping Constructs. Grouping constructs describe sub-expressions of a regular expression and capture substrings of an input string. The following table lists the grouping constructs. Grouping construct Description Pattern Matches ( subexpression ) Captures the matched subexpression and assigns it a zero-based ordinal number. (\w)\1 "ee" in "deep" (?< name >subexpression) Captures the matched subexpression into a named group. (?< double>\w)\k< double> "ee" in "deep" (?< name1 -name2 >subexpression) Defines a balancing group ... Read More

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

Arjun Thakur
Updated on 23-Jun-2020 11:21:41

66 Views

Gets or sets the value associated with the specified key. You can also use the Item property to add new elements.If a key does not exist, then you can include it like −myCollection["myNonexistentKey"] = myValueThe following is the code showing how to work with Item property of Hashtable class in C#.Example Live Demousing System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {          Hashtable ht = new Hashtable();          ht.Add("One", "Amit");          ht.Add("Two", "Aman");          ht.Add("Three", "Raman");       ... Read More

Difference between Var and Dynamics in C#

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

262 Views

Var is strictly typed in C#, whereas dynamic is not strictly typed. Var declaration var a = 10; Dynamic declaration dynamic a = 10; A Var is an implicitly typed variable, but it will not bypass the compile time errors. Example of var in C# var a = 10; a = "Demo"; // gives compile error Example of dynamics in C# dynamic a = 10; a = "Demo"; // won’t give error

Explain C# Quantifiers in regular expression

Chandu yadav
Updated on 30-Jul-2019 22:30:23

251 Views

Quantifiers in C# specify how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur. Quantifier Description Pattern Matches * Matches the previous element zero or more times. \d*\.\d ".0", "19.9", "219.9" + Matches the previous element one or more times. "be+" "bee" in "been", "be" in "bent" ? Matches the previous element zero or one time. "rai?n" "ran", "rain" { n } Matches the previous element exactly n ... Read More

Debug Class vs Debugger Class in C#

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

241 Views

To debug your code, you need methods or properties, which are provided by Debug Class in C#. The debugger class is used to set communication with the debugger. Debug Class The Debug class inherits from System.Diagnostics. The syntax is − public static class Debug The following are the properties of the debugger class. Sr.No Property & Description 1 AutoFlush Gets or sets a value stating whether Flush should be called on the Listeners or not. 2 IndentLevel The indent level is set 3 IndetntSize The number of spaces in the ... Read More

Delete nth element from headnode using C#

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

92 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; } // n points to the node before the node we wish to delete Node n = head; // m is the node set to be deleted Node m = head.Next; for (int i = 2; i < val; i++) {    n = n.Next;    m = m.Next; } ... Read More

Advertisements