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 by Chandu yadav
Page 13 of 81
Create Dismissal Alerts in Bootstrap
To create a dismissal alert −Add a basic alert by creating a wrapper and adding a class of .alert and one of the four contextual classes, for example, .alert-success, .alert-info, etc.Also add optional .alert-dismissable to the above class.Add a close button.You can try to run the following code to create dismissal alerts −Example Bootstrap Example × Success! Well done its submitted. × Info! Take this info.
Read MoreWhy is the Main() method use in C# static?
The Main method states what the class does when executed and instantiates other objects and variables.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 following shows how to add a Main() method with static −Exampleusing System; namespace Demo { class HelloWorld { static void Main(string[] args) { Console.WriteLine("Bingo!"); Console.ReadKey(); } } }OutputBingo!As you can see in the ...
Read MoreAll Method in C#
The All() extension method is part of the System.Linq namepspace. Using this method, you can check whether all the elements match a certain condition or not.Set an array −int[] arr = { 6, 7, 15, 40, 55 };The following is an example. It checks whether all the elements in the array is greater than and equal to 2 or not −arr.All(element => element > = 2);Here is the complete code −Exampleusing System; using System.Linq; class Program { static void Main() { int[] arr = { 6, 7, 15, 40, 55 }; bool res = arr.All(element => element >= 2); Console.WriteLine(res); } }OutputTrue
Read MoreHow to generate the first 100 Odd Numbers using C#?
To generate first 100 odd numbers, set a for loop from 1 to 100.for(val = 1; val
Read MoreDifferent ways for Integer to String Conversions in C#
The easiest way to convert an integer to a string in C# is using the ToString() method.Let us see an example −int a = 100; string str = a.ToString();Another way is to use Convert.ToString();b = 50; string str2 = Convert.ToString(b); Console.WriteLine(str2);The following is the example showing the different ways to convert integer to string.Exampleusing System; class Program { static void Main() { int a, b, c; a = 10; string str = a.ToString(); Console.WriteLine(str); b = 50; string str2 = Convert.ToString(b); Console.WriteLine(str2); c = 100; string str3 = string.Format("{0}", c); Console.WriteLine(str3); } }Output10 50 100
Read MoreC# Program to split a string on spaces
Firstly, set a string −string str = "Science and Mathematics";Now use the Split() method to split wherever the spaces occur −str.Split(' ')The following is the complete code −Exampleusing System; using System.Linq; using System.IO; class Program { static void Main() { string str = "Science and Mathematics"; Console.WriteLine("String..."+str); string[] myStr = str.Split(' '); Console.WriteLine("Splitted String..."); foreach (string ch in myStr) { Console.WriteLine(ch); } } }OutputString... Science and Mathematics Splitted String... Science and Mathematics
Read MoreBootstrap Filter list
To create a filter list, use the .list-group class in Bootstrap.You can try to run the following code to create a filter list −Example Bootstrap Example Tutorials Java jQuery PHP AngularJS Ruby C $(document).ready(function(){ $("#demo").on("keyup", function() { var value = $(this).val().toLowerCase(); $("#newList li").filter(function() { $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1) }); }); });
Read MoreSet 6-item tuple in C#’
With C#, you can easily set a 6-item tuple.The following is a 6-item tuple −var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000);above, we have tuple for string, string array and int as shown below −TupleHere is the complete code −Exampleusing System; class Demo { static void Main() { var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000); // Displaying Item 1 Console.WriteLine(myTuple.Item1); // Displaying Item 5 Console.WriteLine(myTuple.Item5); // Displaying Item 6 Console.WriteLine(myTuple.Item6); } }Outputelectronics 500 1000
Read MoreWhat does the @ prefix do on string literals in C#?
The @prefix states hat you don't need to escape special characters in the string following to the symbol.The following statement@"D:ew"is equal to:"D:ew"The @ prefix is also used if you want to have large strings and want it to be displayed across multiple lines. The following is an example showing multi-line string −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { string str = @"Welcome User, Kindly wait for the image to load"; Console.WriteLine(str); } } }OutputWelcome User, Kindly wait for the image to load
Read MoreC# program to get the file name in C#
Set the path name in a string −string myPath = "D:ew\quiz.txt";Now, use the GetFileName() method to get the name of the file −Path.GetFileName(myPath)The following is the complete code −Exampleusing System; using System.IO; namespace Demo { class Program { static void Main(string[] args) { string myPath = "D:ew\quiz.txt"; // get extension Console.WriteLine("Extension: "+Path.GetExtension(myPath)); // get path Console.WriteLine("File Path: "+Path.GetFileName(myPath)); } } }OutputExtension: .txt File Path: D:ew\quiz.txt
Read More