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
-
Economics & Finance
Articles by karthikeya Boyini
Page 54 of 143
C# Program to Convert Character case
Let’s say your string is −str = "AMIT";To convert the above uppercase string in lowercase, use the ToLower() method −Console.WriteLine("Converted to LowerCase : {0}", str.ToLower());ExampleThe following is the code in C# to convert character case.using System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { string str; str = "AMIT"; Console.WriteLine("UpperCase : {0}", str); // convert to lowercase Console.WriteLine("Converted to LowerCase : {0}", str.ToLower()); Console.ReadLine(); } } }OutputUpperCase : AMIT Converted to LowerCase : amit
Read MoreGet the creation time of a file in C#
To get the creation time of a file in C#, use the CreationTime() method.For this, use the FileInfo as well as DateTime classes.Create an object of each −FileInfo file = new FileInfo("new.txt"); DateTime dt = file.CreationTime;Let us see the complete code −Exampleusing System.IO; using System; public class Program { public static void Main() { using (StreamWriter sw = new StreamWriter("qa.txt")) { sw.WriteLine("Questions and Answers!"); } FileInfo file = new FileInfo("qa.txt"); // file creation time DateTime dt = file.CreationTime; Console.WriteLine(dt); } }Output9/5/2018 5:20:03 AM
Read MoreLiteral number suffixes in C#
To specify number types, use suffixes in C#. Literal number suffixes are numeric suffixes.For example, for long type −// long suffix long val1 = 29345L;For double type −// double suffix double val2 = 297.325D; Console.WriteLine(val2);Let us see more examples −Exampleusing System.IO; using System; public class Program { public static void Main() { // long suffix long val1 = 29345L; Console.WriteLine(val1); // decimal suffix decimal val5 = 3245.5678M; Console.WriteLine(val5); // double suffix double val2 = 297.325D; Console.WriteLine(val2); // float suffix float val3 = 250.35F; Console.WriteLine(val3); // unsigned suffix uint val4 = 3456U; Console.WriteLine(val4); } }Output29345 3245.5678 297.325 250.35 3456
Read MoreC# Program to convert first character uppercase in a sentence
Let us say the following is your string −String str = "Welcome to our website!";Create a char array of the string included above using the ToCharArray() method:char []ch = str.ToCharArray();To convert the first character to uppercase −if (ch[i] >= 'a' && ch[i] = 'a' && val[i] = 'A' && val[i]
Read MoreHow to call a method of a class in C#
To call a method, use the name of the method after the object name, for example, −obj1. Display();Let’s say the class name is ApplicationOne, so to call the method −ApplicationOne one = new ApplicationOne(); //calling the displayMax method ret = one.displayMax(a, b);The following is the example showing how to call a method in C# −Exampleusing System; namespace Demp { class ApplicationOne { public int displayMax(int num1, int num2) { /* local variable declaration */ int result; if (num1 > num2) ...
Read MoreRandom Numbers in C#
To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values.Next(100,200);We have set the above method under Random() object.Random rd = new Random(); int rand_num = rd.Next(100,200);The following is an example −Exampleusing System; class Program { static void Main() { Random rd = new Random(); int rand_num = rd.Next(100,200); Console.WriteLine(rand_num); } }Output182
Read MoreCreate a tabbed menu with Bootstrap
To create a tabbed menu with Bootstrap, you can try to run the following codeExample Bootstrap Example Database The following are the database technologies: DB2 MySQL SQL CouchDB
Read MoreHow to generate the first 100 even Numbers using C#?
To generate first 100 even numbers, set a for loop from 1 to 100.for(val = 1; val
Read MoreBootstrap Accordion
To create an Accordion in Bootstrap, you can try to run the following codeExample Bootstrap Example My Website Tutorials We provide tutorials on C, C++, Java, PHP, Networking, SEO, C++, C, etc. Quiz We provide quizzes on C, C++, Java, PHP, Ruby, DBMS, Networking, SEO, etc.
Read MoreWhat are dynamic arrays in C#?
Dynamic arrays are growable arrays and have an advantage over static arrays. This is because the size of an array is fixed.To create arrays dynamically in C#, use the ArrayList collection. It represents an ordered collection of an object that can be indexed individually. It also allows dynamic memory allocation, adding, searching and sorting items in the list.The following is an example showing how to create arrays dynamically in C# −Exampleusing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { ArrayList al = new ArrayList(); ...
Read More