Found 2628 Articles for Csharp

How to remove element from the specified index of the List in C#?

AmitDiwan
Updated on 11-Dec-2019 05:33:07

169 Views

To remove the element from the specified index of the List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       List list = new List();       list.Add("Ryan");       list.Add("Kevin");       list.Add("Andre");       list.Add("Tom");       list.Add("Fred");       list.Add("Jason");       list.Add("Jacob");       list.Add("David");       Console.WriteLine("Count of elements in the List = "+list.Count);       Console.WriteLine("Enumerator iterates through the list elements...");       List.Enumerator demoEnum = list.GetEnumerator();     ... Read More

How to play user modified Beep sound through Console in C#?

AmitDiwan
Updated on 11-Dec-2019 05:29:51

256 Views

To play user modified beep sound through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       Console.WriteLine("Displaying standard output stream...");       Console.WriteLine("Standard Output Stream = "+Console.Out);       Console.WriteLine("Beep sound through Console");       Console.Beep();       Console.WriteLine("Beep sound through Console with frequence 1000 hertz and duration 500 milliseconds");       Console.Beep(1000, 500);    } }OutputThis will produce the following output −Displaying standard output stream... Standard Output Stream = System.IO.TextWriter+SyncTextWriter Beep sound through Console Beep sound through Console with frequence 1000 ... Read More

How to get the HashCode of the tuple in C#?

AmitDiwan
Updated on 11-Dec-2019 05:26:36

117 Views

To get the HashCode of the tuple, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(50, 100));       var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500, Tuple.Create(100, 200));       Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2));       Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode());       Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode());    } }OutputThis will produce the following output −Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = ... Read More

How to create a StringCollection in C#?

AmitDiwan
Updated on 11-Dec-2019 05:22:56

63 Views

To create a StringCollection in C#, the code is as follows −Example Live Demousing System; using System.Collections.Specialized; public class Demo {    public static void Main(){       StringCollection strCol = new StringCollection();       String[] strArr = new String[] { "A", "B", "C", "D", "E", "F", "G", "H" };       Console.WriteLine("StringCollection elements...");       foreach (string str in strArr){          Console.WriteLine(str);       }       strCol.AddRange(strArr);       Console.WriteLine("Element at 5th index = "+strCol[5]);       Console.WriteLine("Count of strings in StringCollection = " + strCol.Count);    } ... Read More

How to create a shallow copy of SortedList Object in C#?

AmitDiwan
Updated on 11-Dec-2019 05:10:26

128 Views

To create a shallow copy of SortedList object, the code is as follows −Example Live Demousing System; using System.Collections; public class Demo {    public static void Main(String[] args){       SortedList list = new SortedList();       list.Add("A", "Jacob");       list.Add("B", "Sam");       list.Add("C", "Tom");       list.Add("D", "John");       list.Add("E", "Tim");       list.Add("F", "Mark");       list.Add("G", "Gary");       list.Add("H", "Nathan");       list.Add("I", "Shaun");       list.Add("J", "David");       Console.WriteLine("SortedList elements...");       foreach(DictionaryEntry d in list){     ... Read More

How to play Beep sound through Console in C#?

AmitDiwan
Updated on 11-Dec-2019 05:05:47

156 Views

To play beep sound through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(String[] args){       Console.WriteLine("Displaying standard output stream...");       Console.WriteLine("Standard Output Stream = "+Console.Out);       Console.WriteLine("Beep sound through Console");       Console.Beep();    } }OutputThis will produce the following output −Displaying standard output stream... Standard Output Stream = System.IO.TextWriter+SyncTextWriter Beep sound through ConsoleExampleLet us now see another example − Live Demousing System; public class Demo {    public static void Main(String[] args){       Console.WriteLine("Displaying standard output stream...");       Console.WriteLine("Standard ... Read More

How to perform a specified action on each element of the List in C#?

AmitDiwan
Updated on 11-Dec-2019 05:03:03

147 Views

To perform a specified action on each element of the List, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void demo(int s){       s = s * 10;       Console.WriteLine(s);    }    public static void Main(String[] args){       List list = new List();       list.Add(25);       list.Add(50);       list.Add(75);       list.Add(100);       list.Add(200);       list.Add(250);       list.Add(275);       list.Add(300);       Console.WriteLine("List...");       foreach (int ... Read More

How to insert the elements of a collection into the List at the specified index in C#?

AmitDiwan
Updated on 10-Dec-2019 12:27:32

213 Views

To insert the elements of a collection into the List at the specified index, the code is as follows −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       string[] strArr = { "John", "Tom", "Kevin", "Mark", "Gary" };       List list = new List(strArr);       Console.WriteLine("Elements in a List...");       foreach(string str in list){          Console.WriteLine(str);       }       strArr = new string[] { "Demo", "Text" };       Console.WriteLine("Inserted new elements in a range...");     ... Read More

How to get TypeCode in C#?

AmitDiwan
Updated on 10-Dec-2019 12:25:28

115 Views

To get TypeCode in C#, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(){       string s = "Demo";       Console.WriteLine("String = " +s);       Console.WriteLine("String Type = " +s.GetType());       Console.WriteLine("GetTypeCode = " +s.GetTypeCode());    } }OutputThis will produce the following output −String = Demo String Type = System.String GetTypeCode = StringExampleLet us now see another example − Live Demousing System; public class Demo {    public static void Main(){       int i = 100;       double d = 5.26d; ... Read More

How to get the Standard Input and Output Stream through Console in C#?

AmitDiwan
Updated on 10-Dec-2019 12:23:12

290 Views

To get the standard input stream through Console, the code is as follows −Example Live Demousing System; public class Demo {    public static void Main(string[] args){       Console.WriteLine("Displaying standard input stream...");       Console.WriteLine("Standard Input Stream = "+Console.In);    } }OutputThis will produce the following output −Displaying standard input stream... Standard Input Stream = System.IO.TextReader+SyncTextReaderExampleLet us now see an example to display standard output stream − Live Demousing System; public class Demo {    public static void Main(string[] args){       Console.WriteLine("Displaying standard output stream...");       Console.WriteLine("Standard Output Stream = "+Console.Out);    } }OutputThis will ... Read More

Advertisements