冒泡排序
int[] array = { 25,21,50,41,10};
for (int i = 0; i < array.Length; i++)
{
for (int j = 0; j < array.Length-1-i; j++)
{
if (array[j]<array[j+1])
{
int temp = array[j];
array[j] = array[j+1];
array[j + 1] = temp;
}
}
}
for (int i = 0; i < array.Length; i++)
{
Console.Write(array[i]+"-");
}
Console.ReadLine();
变色动画(背景颜色,边框厚度,边框颜色,透明度动画)
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Border br = new Border();
br.Width = br.Height = 200;
Canvas.SetLeft(br,100);
Canvas.SetTop(br, 100);
XZ.Children.Add(br);
br.Background = Brushes.Red;
br.BorderThickness = new Thickness(10);
br.BorderBrush = Brushes.Blue;
br.Opacity = 1;
Storyboard story = new Storyboard();
//背景颜色动画
ColorAnimation coloran = new ColorAnimation(Colors.Red,Colors.Pink,new Duration(TimeSpan.FromSeconds(3)));
Storyboard.SetTarget(coloran, br);
Storyboard.SetTargetProperty(coloran, new PropertyPath("(Border.Background).(SolidColorBrush.Color)"));
story.Children.Add(coloran);
//边框颜色动画
ColorAnimation colorbor = new ColorAnimation(Colors.Blue, Colors.Plum, new Duration(TimeSpan.FromSeconds(3)));
Storyboard.SetTarget(colorbor, br);
Storyboard.SetTargetProperty(colorbor, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
story.Children.Add(colorbor);
//边框厚度动画
ThicknessAnimation ta = new ThicknessAnimation(new Thickness(30),new Thickness(0),new Duration(TimeSpan.FromSeconds(5)));
Storyboard.SetTarget(ta, br);
Storyboard.SetTargetProperty(ta, new PropertyPath("BorderThickness"));
story.Children.Add(ta);
//透明度动画
DoubleAnimation da = new DoubleAnimation(1,0,new Duration(TimeSpan.FromSeconds(5)));
Storyboard.SetTarget(da,br);
Storyboard.SetTargetProperty(da, new PropertyPath("Opacity"));
story.Children.Add(da);
story.Begin();
}