IEnumerable<Point> GetPoints(int points) // points - количество вершин
{
return Enumerable.Range(0, points)
.Select(i => 2 * i * Math.PI / points)
.Select(arg => new Point
{
X = Math.Cos(arg),
Y = Math.Sin(arg)
});
}
struct Point
{
public double X;
public double Y;
}
public class MyNumeric<T> where T : struct, IComparable<T>, IEquatable<T>, IConvertible
{
public static readonly T MaxValue = ReadStaticField("MaxValue");
public static readonly T MinValue = ReadStaticField("MinValue");
private static T ReadStaticField(string name)
{
FieldInfo field = typeof(T).GetField(name, BindingFlags.Public | BindingFlags.Static);
if (field == null)
{
throw new InvalidOperationException("Нечисловой тип: " + typeof(T).Name);
}
return (T)field.GetValue(null);
}
}
Console.WriteLine(MyNumeric<int>.MaxValue);
Console.WriteLine(MyNumeric<float>.MinValue);
var xml = XDocument.Parse(
@"<?xml version='1.0' encoding='utf-8'?>
<!-- This is a SCORM 1.2 manifest file, created 9/1/2014 1:52:58 PM by semina using CourseLab 140211 -->
<manifest xmlns='http://www.imsproject.org/xsd/imscp_rootv1p1p2' xmlns:adlcp='http://www.adlnet.org/xsd/adlcp_rootv1p2' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation=' http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd' identifier='MANIFEST-5D060C55_4EC0_4E49_8D2F_F5C934FFEDAD' version='1.0'>
<title>Технолог подсистемы САДД БР. Работа с модулем «Справочники»</title>
<item identifier='im_1' identifierref='RES1' parameters='?width=1152&height=920'>
<title>Информационный материал</title>
</item>
<item identifier='im_1' identifierref='RES1' parameters='?width=1152&height=920'>
<title>Информационный материал</title>
</item>
</manifest>");
var ns = xml.Root.GetDefaultNamespace();
foreach (var element in xml.Root.Descendants().Where(e => e.Name == ns + "item"))
{
var last = element.Elements().Last();
if (last.Name == ns + "title")
{
last.AddAfterSelf(
new XElement("track",
new XAttribute("id", ""),
new XAttribute("genre", "Break Beat")));
}
}
private void AddTag(bool onstart)
{
if (tagList.InvokeRequired)
tagList.Invoke(new Action(() => BlockUI(onstart)));
else
BlockUI(onstart);
}
private void button1_Click(object sender, System.EventArgs e)
{
var t = new Thread(new ThreadStart(() =>
{
if (button3.InvokeRequired)
{
button3.Invoke(new Action(() =>
{
button1.Text = "new button1 name";
button2.Text = "new button2 name";
button3.Text = "new button3 name";
}));
}
else
{
button1.Text = "new button1 name";
button2.Text = "new button2 name";
button3.Text = "new button3 name";
}
}));
t.Start();
}
private void button1_Click(object sender, System.EventArgs e)
{
var t = new Thread(new ThreadStart(() =>
{
if (InvokeRequired)
{
Invoke(new Action(() =>
{
button1.Text = "new button1 name";
button2.Text = "new button2 name";
button3.Text = "new button3 name";
}));
}
else
{
button1.Text = "new button1 name";
button2.Text = "new button2 name";
button3.Text = "new button3 name";
}
}));
t.Start();
}
dynamic myDinamic = GetDynamic();
myDynamic.SomeMethod();
for (int i = 0; i < RowCount - 1; i++)
{
SortRows(i);
for (int j = i + 1; j < RowCount; j++)
{
if (Matrix[i][i] != 0) //если главный элемент не 0, то производим вычисления
{
double MultElement = Matrix[j][i] / Matrix[i][i];
for (int k = i; k < ColumCount; k++)
Matrix[j][k] -= Matrix[i][k] * MultElement;
RightPart[j] -= RightPart[i] * MultElement;
}
//для нулевого главного элемента просто пропускаем данный шаг
}
}
Parallel.For(0, (int)RowCount, i =>
{
SortRows(i);
for (int j = i + 1; j < RowCount; j++)
{
if (Matrix[i][i] != 0) //если главный элемент не 0, то производим вычисления
{
double MultElement = Matrix[j][i] / Matrix[i][i];
for (int k = i; k < ColumCount; k++)
Matrix[j][k] -= Matrix[i][k] * MultElement;
RightPart[j] -= RightPart[i] * MultElement;
}
//для нулевого главного элемента просто пропускаем данный шаг
}
});