Example of Javascript for website making total money using while and for loop

Say I own 100 websites, where the first 10 website makes £30 each per month and the rest makes £10 each per month. Now, I need to find out what is the total revenue brings by all of my sites. <!doctype html> <html lang=”en_gb1″> <head> <title>Total revenue finder</title> </head> <body> <script> var websiteNumber = 1; var tot1alMoney = 0; var totalWebsite = 100; while (websiteNumber <= 10){ tot1alMoney += 30; document.write(“Site #” +websiteNumber + ” is making money adding total […]






MySQL Nested, banded aggregation

DROP TABLE IF EXISTS Sold, Income; CREATE TABLE sales(employeeID int, sold int); INSERT INTO sold VALUES(1,2),(1,5),(1,7),(2,9),(2,15),(2,12); SELECT * FROM sold; +————+——-+ | employeeID | sold| +————+——-+ |          1 |     2 | |          1 |     5 | |          1 |     7 | |          2 |     9 |






Fetching data from SQL server 2014 in visual studio 2015

// To fetch data from sql server // Step 1: Open a connection string connectionStrings = “Data Source=(LocalDB)\\MSSQLLocalDB;Integrated Security=True;Connect Timeout=30”; SqlConnection objConnection = new SqlConnection(connectionStrings); objConnection.Open(); // Step 2: Fire the command object SqlCommand objCommand = new SqlCommand(“SELECT * from CustomerTable”, objConnection); DataSet objDataSet = new DataSet(); SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand); objAdapter.Fill(objDataSet); // Bind the data to the UI dataGridView1.DataSource = objDataSet; // Close the connection objConnection.Close();  






Methods syntax in C Sharp

[attributes] // attributes are optional access-modifiers return-type method-name (parameters) { // Method Body } Here’s an example of a method in C Sharp using Visual Studio Community Edition 2015 [Reference: Exam 70-480 programming in c#] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace xyz { class Program { public static void Main(string[] args) { Program evenNumbersInstance = new Program(); evenNumbersInstance.EvenNumbers(); Console.ReadLine(); } public void EvenNumbers() { int start = 0; while (start <= 25) { Console.WriteLine(start); start […]






Output even and odd numbers from an Array list in C#

Example below displays output even and odd numbers from an Array list in C#: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace exam70-483 { class ArraysExample { static void Main() { int[] myArray = new int[] { 1, 2, 3, 4, 5, 6, 6, 7, 7, 8, 89, 55, 55, 3, 3 }; var myQuery = from i in myArray group i by (i % 2 == 0) into gEvenOdd select gEvenOdd; foreach (var item in myQuery) […]






Extract Even numbers from a series of numbers

On this example here I will be showing how to extract even numbers from a series of numbers? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EvenNumbersExtract { class EvenNumbers { static void Main() { for (int i = 0; i < 40; i++) { if (i % 2 != 0) { Console.WriteLine(i); } } Console.ReadLine(); } } }  






The Basic Syntax of Delegates with Example in C#

First you need to write a method that the delegate will point to. Then you need to define the delegate type. A delegate instance needs to be created at this point. Now wire the delegate instance to the method created (See no 1 above). Finally, The method needs invoking by using delegate. Here’s an implementation of these: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PracticeFor70_483Exam.Venkat { class DelegatesExample { // Number 2: Let’s create a delegate […]






C#: Different types of Method parameters using Visual Studio 2015

There are 4 types of Method parameters in C# and they are: Value Parameters Reference Parameters Out Parameters and Parameters Arrays 1. Example of Value Parameters: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PracticeFor70_483Exam.Venkat { class DifferentTypesMethodParameter { public static void Main() { int x = 0; DifferentTypesMethodParameter.Method1(x); Console.WriteLine(x); Console.ReadLine(); //or using class name //DifferentTypesMethodParameter methodSimple = new DifferentTypesMethodParameter(); } public static void Method1(int i) { i = 99; } } } Output will be: 0 […]






C#: Displaying Even and Odd Numbers with TargetParameter in Visual Studio

In this example, I created a Main Method and two other Method. First Method which is called “EvenNumbers” which is taking parameter and has a static modifier where other Method “OddNumbers” does not. Basic Method Structure: [Attributes] access-modifiers return-type method-name(parameters) { Method Body goes here. }   using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PracticeFor70_483Exam.Venkat { class Method { public static void Main() { Console.WriteLine(“Even numbers list: “); Method.EvenNumbers(30); Console.WriteLine(“Odd numbers list: “); Method oddnumberslist = new Method(); […]






Advanced C# Generics example

Using Visual Studio 2015 here’s Advanced C# Generics example: Example 1 shows we normally use the following property as follows: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PracticeFor70_483Exam.ClintEastwood { class Generics { static void Main() { var result = new Result { intData=3, stringData=”Anam”}; var result2 = new Result2 { success=true, intData2=23}; var result3 = new Result3 { stringData3=”My Last Name”, intData3=344}; Console.WriteLine(result.intData); Console.WriteLine(result.stringData); Console.WriteLine(result2.success); Console.WriteLine(result2.intData2); Console.WriteLine(result3.stringData3); Console.WriteLine(result3.intData3); Console.ReadLine(); } } public class Result { public int […]