public bool IsBelong(Point point, IGeometryObject geoGeometry)
{
var polygon = ((Polygon) geoGeometry).Coordinates;
var inPolygon = false;
var x = point.Coordinates.Latitude;
var y = point.Coordinates.Longitude;
var points = polygon[0].Coordinates;
for (var i = 0; i < points.Count - 1; i++)
{
if (((points[i + 1].Longitude > y) != (points[i].Longitude >= y))
&&
(x < (points[i].Latitude - points[i + 1].Latitude) * (y - points[i + 1].Longitude) / (points[i].Longitude - points[i + 1].Longitude) + points[i + 1].Latitude))
{
inPolygon = !inPolygon;
}
}
return inPolygon;
}
static void Main(string[] args)
{
var str = "{1|2|4}{1|3|3}{2|2|3}{1|1|3}";
var number = new [] { "3", "2", "1", "2" };
var temp = str
.Trim('{', '}')
.Split(new []{ "}{" }, StringSplitOptions.None)
.Select(x => x.Split('|').ToArray())
.ToArray();
var result = new StringBuilder();
for (var i = 0; i < temp.Length; i++)
{
var isParse = int.TryParse(number[i], out int index);
if (isParse)
{
result.Append(temp[i][index - 1]);
}
}
Console.WriteLine(result);
Console.ReadKey();
}
abstract class A
{
protected string _value;
}
class B : A
{
// Через общее отнаследованное поле
public string ValueB { get { return _value; } set { _value = value; } }
}
class C : A
{
private string _valueC;
public C(string any)
{ }
// Через конструктор
public C(string any)
{
_valueC = any;
}
public string ValueC { get { return _value; } set { _value = value; } }
// Через метод
public void SetMethod(string any)
{
_valueC = any
}
}
var b = new B();
var c = new C();
b.ValueB = "any"; // c.ValueC = "any"
// так же как и
c.ValueC = "any"; // b.ValueB = "any"
b.ValueB = "any";
// Через конструктор
var c = new C(b.ValueB);
// Через метод
c.SetMethod(b.ValueB);
class SmtpSetting
{
public string Host {get; set;}
public string Server {get; set;}
public string Port {get; set;}
}
var smptSettings = new List<SmptSetting>
{
new SmptSetting
{
Host = "mail.ru",
Server = "smtp.mail.ru",
Port = 587
},
new SmptSetting
{
Host = "yahoo.co",
Server = "smtp.yahoo.co",
Port = 465
},
...
}
var currentSmtp = smptSettings.FirstOrDefault(x => x.Host == host);
if(currentSmtp != null)
{
var smtp = new SmtpClient(currentSmtp.Server, currentSmtp.Port);
}
MailMessage
есть настройка IsBodyHtml
, установите ее в true. public interface IRepository<T>
{
T Create();
T Read();
T Update();
T Delete();
}
public class Repository<T> where T : IRepository<T>
{
public static Repository<T> CreateRepository()
{
return new Repository<T>();
}
}
class Program
{
static void Main(string[] args)
{
var repository = Repository<Comment>.CreateRepository();
Console.ReadKey();
}
}
public class Comment : IRepository<Comment>
{
public int Id { get; set; }
public string Name { get; set; }
public Comment Create()
{
return this;
}
public Comment Read()
{
return this;
}
public Comment Update()
{
return this;
}
public Comment Delete()
{
return this;
}
}
static void Main(string[] args)
{
var comments = new[]
{
new Comment { Id = 1, Text = "1" },
new Comment { Id = 2, Text = "2" },
new Comment { Id = 3, Text = "3" },
new Comment { Id = 4, Text = "1" },
new Comment { Id = 5, Text = "2" },
new Comment { Id = 6, Text = "2" },
new Comment { Id = 7, Text = "1" },
new Comment { Id = 8, Text = "4" },
new Comment { Id = 9, Text = "5" },
new Comment { Id = 10, Text = "2" },
};
var result = comments
.GroupBy(x => x.Text)
.SelectMany(x => x.Select(y => y.Id).Skip(1))
.ToArray();
foreach (var id in result)
{
Console.WriteLine($"{id}");
}
Console.ReadKey();
}
class Comment
{
public int Id { get; set; }
public string Text { get; set; }
}
var item = lstTasks.SelectedItem as DataRowView;
if(item == null)
return throw new NullReferenceExeption(nameof(item));
var resultId = item.TryGetValue("id", out int id);
var resultName = item.TryGetValue("name", out string name);
if(resultId && resultName)
DeleteTask(id.ToString(), name);
как я понимаю самой Visual Studio
for(var i = arr.Count - 1; i >= 0; i--)
{
if(arr[i].Name == "Any")
{
arr.RemoveAt(i);
}
}
arr.RemoveAll(x => x.Name == "Any");
arr.Where(x => x.Name != "Any");