Enlaces interesantes 625
6 days ago
Search form is empty!
[merge]
tool = p4merge
[mergetool]
keepBackup = false
prompt = false
@echo off
:Variables
SET DatabaseBackupPath=\\DatabasePath\
echo %DATE% %TIME%: Starting scheduled task >> "log.txt"
echo %DATE% %TIME%: Copy prod database backup >> "log.txt"
FOR /F "delims=|" %%I IN ('DIR "%DatabaseBackupPath%\*.bak" /B /O:D') DO SET NewestFile=%%I
copy "%DatabaseBackupPath%\%NewestFile%" "E:\Production DB copy\" /z
echo %DATE% %TIME%: Restore Sys Database >> "log.txt" :sqlcmd -S DbServerName -U UserName -P Password -o "DBlog.txt" -d master -Q ^ :"RESTORE DATABASE DbName ^ :FROM DISK = N'E:\Production DB copy\%NewestFile%' WITH REPLACE"
echo %DATE% %TIME%: Execute 'Export images delta' job >> "log.txt" osql -S "SQL11CTMD" -U UserName -P UserPassword -d master -Q"exec msdb.dbo.sp_start_job 'Export images delta'"
USE AdventureWorks2012; -- Get information from the address table for people SELECT * FROM Person.Address; -- Get the state or province associated with the ID 79 SELECT * FROM Person.Address WHERE AddressID = 79;
-- Update the middle name to an initial UPDATE Person.Person SET MiddleName = 'Angela' WHERE FirstName = 'Gail' AND LastName = 'Erickson'
-- Return all information from the culture table
SELECT *
FROM Production.Culture;
-- Insert a new value into the culture table
INSERT INTO Production.Culture
VALUES ('ca-fr', 'Canadian French', GETDATE());
-- Delete an item from the culture table DELETE FROM Production.Culture WHERE CultureID = 'ca-fr';

class Animal
{
// member variables (attributes)
private string type;
private double weight;
private string color;
// properties
public string Type
{
get
{
return type;
}
set
{
type = value;
}
}
public double Weight
{
get
{
return weight;
}
set
{
weight = value;
}
}
public string Color
{
get
{
return color;
}
set
{
color = value;
}
}
// instance methods
public virtual void MakeNoise()
{
Console.WriteLine("Animal is making noise");
}
public void Move()
{
Console.WriteLine("Animal is moving");
}
}
In our example, "MakeNoise" and "Move" are methods quite abstract because they are shared by all the animals in the world. Imagine we create a Dog class which inherits (sub) from our Animal (super) class, then, we will be able to access all the information in our father (properties and methods) and even change it to align with the way a dog moves or makes noise. To do this you just need to add the name of the father class on the right of your class name like here: public class Dog : Animal// Empty class inherits from Animal
class Dog : Animal { }
class Program
{
static void Main(string[] args)
{
// Tobby is our object from the Dog class.
Dog Tobby = new Dog();
Tobby.Color = "black";
Tobby.Weight = 45;
Tobby.MakeNoise();
}
}
class Dog : Animal
{
// attributes
private string breed;
// properties
public string Breed
{
get
{
return breed;
}
set
{
breed = value;
}
}
// We add a new method for our Dog which cannot exist in the Animal class
public void WagTail()
{
Console.WriteLine("Dog wags tail.");
}
// Here we are changing the functionality of our MakeNoise() method.
public override void MakeNoise()
{
Console.WriteLine("Bark!!!");
}
}
class Program
{
static void Main(string[] args)
{
Dog Tobby = new Dog();
Animal myAnimal = new Animal();
Tobby.MakeNoise();
myAnimal.MakeNoise();
// OUTPUT
// Bark!!!
// Animal is making noise
}
}
string CustomerName = "Roberto";
const int MondthsInYear = 12;
int myAge = 30; // Age is a number, we use integer data type. string myAge = "30"; // Age saved as text. string myName = "Mike"; // The name is text so we use string as data type. double myHeight = 1,86; // Height is decimal so we use double instead of integer.
// Array sample. We've created an array of datatype = strings
string[] myArray = new string[] { "Item1", "Item2", "Item3", "Item4" };
Console.WriteLine("Item at index 2 is: " + myArray[2]);
// OUTPUT => Item at index 2 is: Item3
Console.WriteLine("This is the contents of the array.");
foreach (string value in myArray)
{
Console.WriteLine(value);
}
// OUTPUT:
// This is the contents of the array.
// Item1
// Item2
// Item3
// Item4
// Stack sample
Stack myStack = new Stack();
myStack.Push("Item1");
myStack.Push("Item2");
myStack.Push("Item3");
myStack.Push("Item4");
myStack.Push("Item5");
myStack.Push("Item6");
Console.WriteLine("Initial stack count: " + myStack.Count);
// OUTPUT:
//Initial stack count: 6
while (myStack.Count > 0)
{
Object item = myStack.Pop();
Console.WriteLine("Popped" + item.ToString() + " off the stack");
Console.WriteLine("Stack count: " + myStack.Count);
}
// OUTPUT:
// PoppedItem6 off the stack
// Stack count: 5
// PoppedItem5 off the stack
// Stack count: 4
// PoppedItem4 off the stack
// Stack count: 3
// PoppedItem3 off the stack
// Stack count: 2
// PoppedItem2 off the stack
// Stack count: 1
// PoppedItem1 off the stack
// Stack count: 0
// Queue sample
Queue myQueue = new Queue();
myQueue.Enqueue("Item1");
myQueue.Enqueue("Item2");
myQueue.Enqueue("Item3");
myQueue.Enqueue("Item4");
myQueue.Enqueue("Item5");
myQueue.Enqueue("Item6");
myQueue.Enqueue("Item7");
myQueue.Enqueue("Item8");
// Gets the first item
Console.WriteLine(myQueue.Peek());
// OUTPUT:
// Item1
Console.WriteLine(myQueue.Count);
// OUTPUT:
// 8
Object qValue = myQueue.Dequeue();
Console.WriteLine(qValue.ToString());
Console.WriteLine("Queue count is: " + myQueue.Count);
Console.WriteLine(myQueue.Peek());
// OUTPUT:
// Item1
// Queue count is: 7
// Item2
// Dictionary sample DictionarymyDictionary = new Dictionary (); myDictionary.Add("key1", "First Item"); myDictionary.Add("key2", "Second Item"); myDictionary.Add("key3", "Third Item"); myDictionary.Add("key4", "Fourth Item"); Console.WriteLine("Item represented by the key 'key3': " + myDictionary["key3"]); // OUTPUT: // Item represented by the key 'key3': Third Item myDictionary.Remove("key4");
// if sample
int condition1 = 1;
if (condition1 == 1)
{
Console.WriteLine("The condition is true!");
}
Console.WriteLine("This executes after the if, regardless the condition.");
//OUTPUT:
// The condition is true!
// This executes after the if, regardless the condition.
// if-else sample
int condition1 = 1;
if (condition1 == 1)
{
Console.WriteLine("condition TRUE");
}
else
{
Console.WriteLine("condition FALSE");
}
// if-else-if sample
int condition1 = 1;
int condition2 = 2;
if (condition1 == 2)
{
Console.WriteLine("condition1 is TRUE");
}
else if (condition2 == 1)
{
Console.WriteLine("condition1 is TRUE");
}
else
{
Console.WriteLine("Neither condition is true.");
}
// switch sample
int switchCondition = 3;
switch (switchCondition)
{
case 1:
Console.WriteLine("Value is 1");
break;
case 2:
Console.WriteLine("Value is 2");
break;
case 3:
Console.WriteLine("Value is 3");
break;
case 4:
Console.WriteLine("Value is 4");
break;
default:
Console.WriteLine("Value is " + switchCondition);
break;
}
// for loop sample
Console.WriteLine("for loop");
for (int forCounter = 0; forCounter < 4; forCounter++)
{
Console.WriteLine("forcounter is at " + forCounter);
}
// OUTPUT:
// forcounter is at 0
// forcounter is at 1
// forcounter is at 2
// forcounter is at 3
// while sample
int whileCounter = 0;
while (whileCounter < 3)
{
Console.WriteLine("whileCounter is at " + whileCounter);
whileCounter++;
}
// OUTPUT
// whileCounter is at 0
// whileCounter is at 1
// whileCounter is at 2
// do while sample
int doCounter = 0;
do
{
Console.WriteLine("doCounter is at " + doCounter);
doCounter++;
} while (doCounter < 3);
// OUTPUT
// doCounter is at 0
// doCounter is at 1
// doCounter is at 2
// doCounter is at 3
// recursion sample
long value = Factorial(10);
Console.WriteLine(value);
static long Factorial(int n)
{
if (n == 0)
{
return 1;
}
return n * Factorial(n - 1);
}
#content {
margin-left: 20px;
float: left;
background-color: #ffffff;
border-radius: 10px;
}

function draw() {
var canvas = document.getElementById("board");
if (canvas.getContext) {
var context = canvas.getContext("2d");
context.beginPath();
context.moveTo(10, 10);
context.lineTo(100, 100);
context.stroke();
}
}
window.onload = draw;
return smart © 2015. All Rights Reserved.
Created by ThemeXpose