Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to print a line on the console using C#?
To display a line, Console.Write() is used in C#.Console displays the result on the console. I have first set a string.string str = "Tom Hanks is an actor";Now displaying the above line.Console.WriteLine(str);The following is the complete code −Exampleusing System; namespace Program { public class Demo { public static void Main(String[] args) { string str = "Tom Hanks is an actor"; Console.WriteLine("Displaying a line below"); Console.WriteLine(str); Console.ReadLine(); } } }OutputDisplaying a line below Tom Hanks is an actor
Read MoreUnion Method in C#
The Union method gets the unique elements from both the lists.Let us set two lists −var list1 = new List{12, 65, 88, 45}; var list2 = new List{40, 34, 65};Now get the union of both the lists −var res = list1.Union(list2);The following is the example −Exampleusing System.Collections.Generic; using System.Linq; using System; public class Demo { public static void Main() { // two lists var list1 = new List{12, 65, 88, 45}; var list2 = new List{40, 34, 65}; // finding union var res = list1.Union(list2); foreach(int i in res) { Console.WriteLine(i); } } }Output12 65 88 45 40 34
Read MoreC# Queryable LongCount Method
Use the Linq LongCount method to get the count of elements.The following is our string array −string[] emp = { "Jack", "Mark"};Now, use the LongCount() method.emp.AsQueryable().LongCount();Here is the complete code.Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo { static void Main() { string[] emp = { "Jack", "Mark"}; long res = emp.AsQueryable().LongCount(); Console.WriteLine("{0} employees in the Department", res); } }Output2 employees in the Department
Read MoreHow to declare a two-dimensional array in C#
A 2-dimensional array is a list of one-dimensional arrays. Declare it like the two dimensional array shown below −int [, ] aTwo-dimensional arrays may be initialized by specifying bracketed values for each row.int [, ] a = new int [4, 4] { {0, 1, 2, 3} , {4, 5, 6, 7} , {8, 9, 10, 11} , {12, 13, 14, 15} };The following is an example showing how to work with two-dimensional arrays in C# −Exampleusing System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { /* an array ...
Read MoreWhy is f required while declaring floats in C#?
The f is a lowercase suffix set while declaring a float. It tells the compiler that the literal is of a specific type.Exampleusing System.IO; using System; public class Program { public static void Main() { float val = 30.22f; Console.WriteLine(val); } }Output30.22Above, we have set the float using f suffix.IEnumerable res = val1.AsQueryable().Intersect(val2);
Read MoreAdd sizes for Bootstrap Buttons
To add size for buttons in Bootstrap, try the following classes:ClassDescription.btn-lgThis makes the button size large..btn-smThis makes the button size small..btn-xsThis makes the button size extra small..btn-blockThis creates block level buttons—those that span the full width of a parent.ExampleYou can try to run the following code to create a small button − Bootstrap Example Small button
Read MoreBootstrap progress class
Use the .progress class in Bootstrap to create a progress bar. The class is a container for progress bars.You can try to run the following code to implement progress class in BootstrapExample Bootstrap Example 90% Complete
Read MoreWhat does the keyword var do in C#?
The "var" keyword initializes variables with var support. Just assign whatever value you want for the variable, integer, string, float, etc.Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { var myInt = 5; var myString = "Amit"; Console.WriteLine("Rank: {0} Name: {1}",myInt,myString); } } }OutputRank: 5 Name: AmitWe can also use var in arrays −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { var myInt = new int[] {65,43,88,56}; foreach(var val in myInt) Console.WriteLine(val); } } }Output65 43 88 56
Read MoreC# program to get max occurred character in a String
To get the maximum occurred character in a string, loop until the length of the given string and find the occurrence.With that, set a new array to calculate −for (int i = 0; i < s.Length; i++) a[s[i]]++; }The values we used above −String s = "livelife!"; int[] a = new int[maxCHARS];Now display the character and the occurrence −for (int i = 0; i < maxCHARS; i++) if (a[i] > 1) { Console.WriteLine("Character " + (char) i); Console.WriteLine("Occurrence = " + a[i] + " times"); }Let us see the complete code ...
Read MoreBootstrap .btn-block class
To create a button using the .btn-block class, you can try to run the following code −Example Bootstrap Example The following are block level buttons: Block level Primary button Block level button
Read More