using System;
namespace AddRemoveTest
{
public class Program
{
public static void Main(string[] args)
{
var a = new A();
a.MyEvent += (s,e) => {Console.WriteLine("Event");};
a.MyEvent -= (s,e) => {Console.WriteLine("Event");};
}
}
public class A
{
public event EventHandler MyEvent
{
add{
Console.WriteLine("Add event");
}
remove{
Console.WriteLine("Remove event");
}
}
}
}
// Вывод:
// Add event
// Remove event
<ItemsControl>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}" Foreground="{Binding ForeColor}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
var str = "Толщина: 9 см<br><br>Длина: 160 см<br>Ширина: 70 см<br>Детские:Да<br><br>Детские:Да<br><br>Детские:Да<br><br>Детские:Да<br>";
foreach(var s in str.Split(new string[] {"<br>"}, StringSplitOptions.RemoveEmptyEntries).Distinct())
Console.WriteLine(s);
// Подсчёт
var str = "ТОСТЕР";
var result = 0;
foreach(var ch in str)
{
result |= (1 << ((int)ch - (int)'А'));
}
// Вывод результата
for(var i = 0; i < 32; i++)
{
if((result & (1 << i)) == (1 << i))
Console.WriteLine((char) ((int)'А' + i));
}
// Вывод:
// Е
// О
// Р
// С
// Т
private List<System.DayOfWeek> _dayWeeks = new List<System.DayOfWeek>();
public List<System.DayOfWeek> DayWeeks
{
get{return _dayWeeks;}
}
public bool HasMonday
{
get{ return _dayWeeks.Any(d => d == DayOfWeek.Monday);}
set
{
if(value && !HasMonday)
{
_dayWeeks.Add(DayOfWeek.Monday);
OnPropertyChanged("DayWeeks");
OnPropertyChanged("HasMonday");
}
if(!value && HasMonday)
{
_dayWeeks.Remove(DayOfWeek.Monday);
OnPropertyChanged("DayWeeks");
OnPropertyChanged("HasMonday");
}
}
}
// Дальше аналогично для других дней недели
using System.Runtime.InteropServices;
[DllImport("myDll.dll", CallingConvention=CallingConvention.StdCall)]
public static extern int Card();
[DllImport("myDll.dll", CallingConvention=CallingConvention.StdCall, Charset=Charset.Ansi)]
public static extern int cudaCard(IntPtr mWnd, IntPtr aWnd, string data, string parms, bool show, bool nopause);
class A
{
public string Name{get;set;}
public A Parent {get;set;}
public IEnumerable<A> Children
{
get
{
return AllItemsOfA.Select(a => a.Parent == this);
}
}
public int Level()
{
int level = 0;
var current = Parent;
while(current != null)
{
current = current.Parent;
level ++;
}
return level;
}
}