Found 34494 Articles for Programming

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

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]

Explain C# Grouping Constructs in regular expression

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

201 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

73 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

278 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

285 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

255 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

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; } // 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

Dictionary Methods in C#

Samual Sam
Updated on 23-Jun-2020 11:26:04

4K+ Views

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.The following are the methods −Sr.NoMethod & Description1AddAdd key-value pairs in Dictionary2Clear()Remove all keys and values3RemoveRemoves the element with the specified key.4ContainsKeyChecks whether the specified key exists in Dictionary.5ContainsValueChecks whether the specified key value exists in Dictionary.6CountCount the number of key-value pairs.7ClearRemoves all the elements from Dictionary.Let us see how to add elements into a Dictionary and display the count.Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       IDictionary d = new Dictionary();     ... Read More

Exception Propagation in C#

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 repeats until the exception is caught. In case, the exception isn’t caught, the execution of the program comes to an end.The above concept is explain in the below example showing nested try statements.Example Live Demousing System; using System.Text; public class Demo {    public static void Main() {       ... Read More

Advertisements