Posts

String class in C# (Methods and properties)

String Methods Substring(): Returns a new string that is a substring of the current string. Concat(): Concatenates two or more strings into a new string. Trim(): Removes leading and trailing white spaces from the string. Replace(): Replaces all occurrences of a specified character or string with another character or string. ToLower(): Converts all characters in the string to lowercase. ToUpper(): Converts all characters in the string to uppercase. Contains(): Returns a boolean indicating whether a specified substring is present in the string. IndexOf(): Returns the zero-based index of the first occurrence of a specified substring. Split(): Splits the string into an array of substrings based on a specified delimiter. StartsWith(): Returns a boolean indicating whether the string starts with a specified prefix. EndsWith(): Returns a boolean indicating whether the string ends with a specified suffix. Join(): Joins an array of strings into a single string using a specified separator. PadLef...

SQL Server Queries

 // Creating a new Database CREATE DATABASE DummyDB // Selecting OR entring in the Database USE DummyDB // Creating a table in our database CREATE TABLE DummyTBL ( ID INT PRIMARY KEY IDENTITY,  Name VarChar(50), Address VarChar(100), Age INT, Gender VarChar(6) ); //Seeing the table which we just have created SELECT * FROM DummyTBL //Inserting record in the table INSERT INTO DummyTBL (Name, Address, Age, Gender) VALUES ('Yogender Joshi', 'Lakhnow', 45, 'Male') //Updating record from the table UPDATE DummyTBL SET Address='Agra' WHERE ID=2 //Deleting record from the table DELETE FROM DummyTBL WHERE ID=11; //Adding a column in the excisting table ALTER TABLE DummyTBL ADD Mobile INT NOT NULL //Deleting a column in any table ALTER TABLE DummyTBL DROP COLUMN Mobile //Rename the table DummyTBL to NewDummyTBL SP_RENAME 'DummyTBL', 'NewDummyTBL' SP_RENAME 'NewDummyTBL', 'DummyTBL' //Rename the column Name to Full Name SP_RENAM...

Logic to swap two numbers without using third variable

Image
// Logic one             a = a + b; // 77 = 32 + 45             b = a - b; // 32 = 77 - 45             a = a - b; // 45 = 77 - 32  // Logic Two             a = a * b; // 1440 = 32 * 45             b = a / b; // 32 = 1440 / 45             a = a / b; // 45 = 1440 / 32

Java Complete Notes [pdf]

Click here to download notes

Program to find the factorial using recursion [Java]

public class Factorial {     static int findFactorial(int n){               if (n == 1)                 return 1;               else                 return(n * findFactorial(n-1));  //calling same method       }        public static void main(String[] args) {   System.out.println("Factorial of 5 is: " + findFactorial(5));   }   } Output: Factorial of 5 is: 120

Simple calculator (Console application/Java)

import java.util.*;  public class calc {     public static void main(String[] args)     {         Scanner sc = new Scanner(System.in);         Double v1, v2 = 0.0;         char decn = 'N';         do {         System.out.println("Which operation do you want to perform (Please select a number)\n"         + "1. Additin\n"         + "2. Subtraction\n"         + "3. Multiplication\n"         + "4. Division\n"         + "5. Modules\n"         + "6. Power");         int ops = sc.nextInt();         switch (ops){         case 1:         System.out.println("Please enter the first nubmer: ");         v1 = sc.nextDouble();   ...