Posts

Showing posts from July, 2023

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