Posts

Showing posts from 2022

What is HTTP Protocol?

Hyper Text Transfer Protocol - Set of rules that govern communication. - Application protocol . - Stateless protocol. - Follows Request -Response pattern. - Designed for Distributed Hypermedia systems. - Standards were developed by Internet Engineering Task Force (IETF) and World Wide Web Consortium (W3C). - Current version=> HTTP/2

Value types in C#

It's the type of memory in C#. It stores both datatype and value. For instance int a=5; It will be stored as    _____ a |int|5|    ______ Examples to value types 1.All int data types 2.bool 3. Enum 4. Struct Value types are available in both heap and stack.

What's the main role of Garbage collector in C#?

Garbage collection is a background process. It's deallocating the memories of dereferenced objects. Garbage collector has some stages to do this. Such Gen0, Gen 1 and so on.

What's the main purpose of Stack in C#?

Stack is used to trace the method calls of C#. It's handled by Common Language Runtime. Stack has lots of Stack frames. Each stack frame has 3 parts. 1. Parameters 2. Return Address 3.Local variables  Stack frame will be removed from stack when the specific method call completes. In this time the local variables will go out of scope.

Difference between Dropdown list and combo box

Dropdown list 1.Non searchable 2.Can't do multiple selection Combo box 1. Searchable 2. Can do multiple selection 

Find the Factorial of given number using C#

 using System; public class Program { public static int  Factorial(int num) { int total=0; for(int i=1;i<=num;i++) {            total=total*i; } return total; } public static void Main() { int nums = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(Factorial(nums)); } }

Find the sum of first 4 biggest array elements using C#

 using System; public class Program { public static int  LargestFour(int[] arr) { Array.Sort<int>(arr);         Array.Reverse(arr); int total=0; for (int n=0;n<5; n++)         {                total += arr[n];                      } return total; } public static void Main() { string test = Console.ReadLine(); int[] nums =   Array.ConvertAll(test.Split(','), int.Parse); Console.WriteLine(LargestFour(nums)); } }

Find the column with the specific text in SQL

 DECLARE     @search_string  VARCHAR(100),     @table_name     SYSNAME,     @table_schema   SYSNAME,     @column_name    SYSNAME,     @sql_string     VARCHAR(2000) SET @search_string = 'test' DECLARE tables_cur CURSOR FOR SELECT DISTINCT T.TABLE_SCHEMA, T.TABLE_NAME FROM INFORMATION_SCHEMA.TABLES T WITH(NOLOCK) INNER JOIN INFORMATION_SCHEMA.COLUMNS C WITH(NOLOCK) ON t.TABLE_SCHEMA=c.TABLE_SCHEMA and t.TABLE_NAME=c.TABLE_NAME AND  c.COLLATION_NAME IS NOT NULL AND t.TABLE_NAME NOT LIKE '%1%' AND t.TABLE_NAME NOT LIKE '%2%'  AND t.TABLE_NAME NOT LIKE '%3%' AND t.TABLE_NAME NOT LIKE '%4%' AND t.TABLE_NAME NOT LIKE '%5%'  AND t.TABLE_NAME NOT LIKE '%6%' AND t.TABLE_NAME NOT LIKE '%7%' AND t.TABLE_NAME NOT LIKE '%8%'  AND t.TABLE_NAME NOT LIKE '%9%' AND t.TABLE_NAME NOT LIKE '%0%' AND t.TABLE_NAME NOT LIKE '%TEMP%'  WHERE TABLE_TYPE = 'BASE TABLE' OPEN tables_...

Law of Demeter

This is a pattern of using proper arrangements. Class Test { public int Add(int x,int y) { Return x+y; } }