Samual Sam

Samual Sam

1,507 Articles Published

Articles by Samual Sam

Page 48 of 151

How does ‘FOR EACH ROW’ work in the MySQL trigger?

Samual Sam
Samual Sam
Updated on 22-Jun-2020 6K+ Views

Actually ‘FOR EACH ROW’ means for each of the matched rows that get either updated or deleted. In other words, we can say that trigger is not applied to each row, it just says to execute the trigger body for each affected table row. We can illustrate this by the following example −ExampleIn this example, we are creating two tables, Sample and Sample_rowaffected, as follows −mysql> Create table Sample(id int, value varchar(20)); Query OK, 0 rows affected (0.47 sec) mysql> Insert into Sample(id, value) values(100, 'same'), (101, 'Different'), (500, 'excellent'), (501, 'temporary'); Query OK, 4 rows affected (0.04 sec) ...

Read More

How to input multiple values from user in one line in C#?

Samual Sam
Samual Sam
Updated on 22-Jun-2020 3K+ Views

Use a while loop to input multiple values from the user in one line.Let’s say you need to get the elements of a matrix. Get it using Console.ReadLine() as shown below −Console.Write("Enter elements - Matrix 1 : "); for (i = 0; i < m; i++) {    for (j = 0; j < n; j++) {       arr1[i, j] = Convert.ToInt16(Console.ReadLine());    } }The following is an example showing how we can input multiple values from user −Example Live Demousing System; namespace Demo {    public class Program {       public static void Main(string[] args) ...

Read More

How can we convert subqueries to INNER JOIN?

Samual Sam
Samual Sam
Updated on 22-Jun-2020 1K+ Views

To make it understand we are using the data from the following tables −mysql> Select * from customers; +-------------+----------+ | Customer_Id | Name     | +-------------+----------+ |           1 | Rahul    | |           2 | Yashpal  | |           3 | Gaurav   | |           4 | Virender | +-------------+----------+ 4 rows in set (0.00 sec) mysql> Select * from reserve; +------+------------+ | ID   | Day        | +------+------------+ |    1 | 2017-12-30 | | ...

Read More

How to convert Decimal to Binary using C#?

Samual Sam
Samual Sam
Updated on 22-Jun-2020 436 Views

Let’s say we want to convert the number 48 to binary.Firstly, set it and use the / and % operators and loop until the value is greater than 1 −decVal = 48; while (decVal >= 1) {    val = decVal / 2;    a += (decVal % 2).ToString();    decVal = val; }Now, display every bit of the binary as shown in the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo {    class MyApplication {       static void Main(string[] args) {          int decVal;         ...

Read More

LinkedList in C#

Samual Sam
Samual Sam
Updated on 22-Jun-2020 2K+ Views

System.Collections.Generic namespace is available in C# for LinkedList. The LinkedList class allows insertion and deletion of elements from the list at a fast pace.C# LinkedList class uses the concept of linked list. It allows us to insert and delete elements fastly. It can have duplicate elements. It is found in System.Collections.Generic namespace.Here is an example −Example Live Demousing System; using System.Collections.Generic; class Demo {    static void Main() {       LinkedList < string > l = new LinkedList < string > ();       l.AddLast("one");       l.AddLast("two");       l.AddLast("three");     ...

Read More

SortedMap Interface in C#

Samual Sam
Samual Sam
Updated on 22-Jun-2020 581 Views

Java has SortedMap Interface, whereas an equivalent of it in C# is SortedList.SortedList collection in C# use a key as well as an index to access the items in a list.A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index. If you access items using an index, it is an ArrayList, and if you access items using a key, it is a Hashtable. The collection of items is always sorted by the key value.Let us see an example to work with ...

Read More

C# program to list the difference between two lists

Samual Sam
Samual Sam
Updated on 22-Jun-2020 2K+ Views

To get the difference between two lists, firstly set two lists in C# −// first list List < string > list1 = new List < string > (); list1.Add("A"); list1.Add("B"); list1.Add("C"); list1.Add("D"); // second list List < string > list2 = new List < string > (); list2.Add("C"); list2.Add("D"); foreach(string value in list2) {    Console.WriteLine(value); }To get the difference, use IEnumerable and Except() as shown below. The difference is shown in the third list −IEnumerable < string > list3; list3 = list1.Except(list2);The following is the complete code −Example Live Demousing System; using System.Collections.Generic; using System.Linq; public class Demo ...

Read More

What is unmanaged code in C#?

Samual Sam
Samual Sam
Updated on 22-Jun-2020 717 Views

The following states what is an unmanaged code −Applications that are not under the control of the CLR are unmanagedThe unsafe code or the unmanaged code is a code block that uses a pointer variable.The unsafe modifier allows pointer usage in unmanaged code.Here is the module showing how to declare and use a pointer variable. We have used the unsafe modifier here.Let us see the example −Examplestatic unsafe void Main(string[] args) {    int var = 20;    int* p = &var;    Console.WriteLine("Data is: {0} ", var);    Console.WriteLine("Address is: {0}", (int)p);    Console.ReadKey(); }

Read More

C# program to convert floating to binary

Samual Sam
Samual Sam
Updated on 22-Jun-2020 842 Views

Let’s say the following is our float −float n = 50.5f;Take an empty string to display the binary value and loop until the value of our float variable is greater than 1 −string a = ""; while (n >= 1) {    a = (n % 2) + a;    n = n / 2; }Let us see the complete example −Example Live Demousing System; using System.IO; using System.CodeDom.Compiler; namespace Program {    class Demo {       static void Main(string[] args) {          // float to binary          Console.WriteLine("float to binary = ");          float n = 50.5f;          string a = "";          while (n >= 1) {             a = (n % 2) + a;             n = n / 2;          }          Console.Write(a);       }    } }Outputfloat to binary = 1.5781251.156250.31250.6251.250.5

Read More

Socket Programming in C#

Samual Sam
Samual Sam
Updated on 22-Jun-2020 2K+ Views

The System.Net.Sockets namespace has a managed implementation of the Windows Sockets interface.It has two basic modes − synchronous and asynchronous.Let us see an example to work with System.Net.Sockets.TcpListener class −TcpListener l = new TcpListener(1234); l.Start(); // creating a socket Socket s = l.AcceptSocket(); Stream network = new NetworkStream(s);The following is the Socket useful in communicating on TCP/IP network −Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); Above, AddressFamily − It is the standard address families by the Socket class to resolve network addressesSocketType − The type of socketProtocolType − This is the network protocol for communication on the Socket. It ...

Read More
Showing 471–480 of 1,507 articles
« Prev 1 46 47 48 49 50 151 Next »
Advertisements