Professional Documents
Culture Documents
C-Sharp
y Advanced Object Oriented y .NET platform y C# has roots in C, C++ and Java y IDE (Visual Studio)
Examples
using System; class Welcome {
static void Main( string[] args ) { Console.WriteLine( "Welcome to C# Programming!" ); }
Examples
using System; using System.Windows.Forms; class Welcome4 { static void Main( string[] args ) { MessageBox.Show( "Welcome\nto\nC#\nprogramming!" ); } }
Examples(Adding 2 numbers)
using System; class Addition { static void Main( string[] args ) { string firstNumber, // first string entered by user secondNumber; // second string entered by user int number1, // first number to add number2, // second number to add sum; // sum of number1 and number2 Console.Write( "Please enter the first integer: " ); firstNumber = Console.ReadLine();
Examples(Adding 2 numbers)
Console.Write( "\nPlease enter the second integer: " ); secondNumber = Console.ReadLine(); number1 = Int32.Parse( firstNumber ); number2 = Int32.Parse( secondNumber ); sum = number1 + number2; Console.WriteLine( "\nThe sum is {0}.", sum ); }// end method Main }// end class Addition
Control Structures
y goto elimination y 3 types of selection structures : y If(single-selection structure) y If/else(double-selection structure) y Switch Case(multiple-selection structure)
Control Structures
y 4 repetition structures y while, y do/while y for y foreach
Math Library
y Console.WriteLine( Math.Sqrt( 900.0 ) ); y If c1 = 13.0, d= 3.0 and f = 4.0, then the statement
Math Library
y Log( x ) y Max( x, y ) y Min( x, y ) y Pow( x, y ) y Sin( x ) y Tan( x )
Arrays
y int[] c = new int[ 12 ]; y int[,] b = new int[ 2, 2 ]; y b[ 0, 0 ] = 1; y b[ 0, 1 ] = 2; y b[ 1, 0 ] = 3; y b[ 1, 1 ] = 4;
y int[,] b = { { 1, 2 }, { 3, 4 } };
Arrays
y int[][] array2 = new int[ 3 ][]; y array2[ 0 ] = new int[] { 1, 2 };
y array2[ 1 ] = new int[] { 3 }; y array2[ 2 ] = new int[] { 4, 5, 6 };
Lists (Looping)
y List<int> list = new List<int>();
list.Add(2); list.Add(3); list.Add(7); foreach (int prime in list) { Console.WriteLine(prime); } for (int i = 0; i < list.Count; i++) { Console.WriteLine(list[i]); }
arr[0] = 2; arr[1] = 3; arr[2] = 5; List<int> list = new List<int>(arr); // Copy to List Console.WriteLine(list.Count); // 3 elements in List
Insert
y List<int> numbers= new List<int>(); // Example List
Data Base
What is a Database?
y A usually large collection of data organized especially
Electronic spreadsheet
y Scenario y . . . Assign one or more employees to a department . . . y . . . Some departments do not yet have assigned employees . . .
Entity
Singular, unique name Uppercase
Attribute
Singular name Lowercase Mandatory marked with * Optional marked with o
assigned to composed of
Query languages
y XQuery is a query language for XML data sources; y XPath is a declarative language for navigating XML
documents; y XSQL is a query language combining the power of XML and the power of SQL, it is currently under development
information is retrieved. column_list includes one or more columns from which data is retrieved. The code within the brackets is optional.
id
age
subject Scie ce
2 9 8
Maths Scie ce
2 3
Stephe Shekar ri a
Fle i g Gowda
SELECT first_name, last_name, age FROM student_details WHERE age BETWEEN 10 AND 15;
first_name ------------Rahul A ajali Shekar last_name ------------Shar a Bhagwat Gowda 2 age ------
id
age
subject Scie ce
2 9 8
Maths Scie ce
2 3
Stephe Shekar ri a
SELECT first_name, last_name, subject FROM student_details WHERE subject IN ('Maths', 'Science');
first_name ------------A ajali Shekar Rahul Stephe last_name ------------Bhagwat Gowda Shar a Fle i g subject ---------Maths Maths Scie ce Scie ce
id
age
subject Scie ce
2 9 8
Maths Scie ce
2 3
Stephe Shekar ri a
SQL ORDER BY
in ascending order by default. ORDER BY Syntax : y SELECT column-list FROM table_name [WHERE condition] [ORDER BY column1 [, column2, .. columnN] [DESC]];
y Example:
SELECT name, salary FROM employee ORDER BY salary; SELECT name, salary FROM employee ORDER BY name, salary;
y is used to sort results either in ascending or descending order. Oracle sorts query results
entire group. These functions are: COUNT, MAX, MIN, AVG, SUM. SQL COUNT (): y This function returns the number of rows in the table that satisfies the condition specified in the WHERE condition
y Example:
SELECT COUNT (*) FROM employee WHERE dept = 'Electronics'; SELECT COUNT (*) FROM employee;