This is how I'd expect a modern millennial to code (you know - the kind of person who considers facts to be particular opinions).
private bool CheckExist(out int id, out bool manageAll, out string orgCode)
{
bool Yes = false;
id = -1;
foreach (DataRow r in dv.Table.Rows)
{
if (r.ItemArray[1].ToString() == TextBoxUsername.Text &&
r.ItemArray[2].ToString() == TextBoxPassword.Text)
{
Yes = true;
id = (int) r.ItemArray[0];
break;
}
}
return Yes;
}
So, so stupid. We now have a pregnant man emoticon. I get the inclusivity thing, but if we want to have equal representation for every possible combination of anything that can happen or can be imagined, then we will run out of resources.
If you have a Unifi CloudKey Gen2+ controller with existing video footage and want to preserve that as well as any configuration settings that might be stored there, but upgrade the capacity of the default HDD from 1TB to something more usable, this article is for you.
dd if=/dev/diskA of=/dev/diskB bs=1m
diskutil list
to find the right drive)Code syntax has become increasingly complex and expressive in recent years. There used to be a time when procedural languages like Java, C, C++, C# were purely procedural and functional languages like Lisp, Erlang were purely (mostly) declarative. Since these are very different mechanisms of programming, when writing code in a specific language a programmer tends to think either declaratively or imperatively.
So consider this simple example problem: An object needs to be created with a list of entries that contain properties describing a specific year and week. Let's say that property is: Hours. So each year / week combination has one property defined called Hours. This object gets instantiated and passed the list of resolved items. It also has a bunch of properties to allow iteration over the years and weeks to build up a grid of Hours and totals. A very naive implementation might look something like this in C#:
class SomeHolder {
private Dictionary<int, Dictionary<int, List<int>>> entities;
public List<int> Years {
List<int> years = new List<int>();
get {
for (int year in entities.Keys)
years.Add(year);
return years;
}
}
public Dictionary<int, List<int>> Weeks {
get {
Dictionary<int, List<int>> weeks = new Dictionary<int, List<int>>();
for (int year in Years) {
if (!weeks.ContainsKey(year))
weeks[year] = new List<int>();
for (int week in entities[year].Keys)
weeks[year].Add(week);
}
return weeks;
}
}
public Dictionary<int, Dictionary<int, int>> WeekTotals {
get {
Dictionary<int, Dictionary<int, int>> totals = new Dictionary<int, Dictionary<int, int>>();
for (int year in Years) {
if (!totals.ContainsKey(year))
totals[year] = new Dictionary<int, int>();
for (int week in Weeks) {
if (!totals[year].ContainsKey(week))
totals[year][week] = 0;
for (int hour in entities[year][week].Values)
totals[year][week] += hour;
}
}
return totals;
}
}
public SomeHolder(Dictionary<int, Dictionary<int, List<int>>> entities) {
this.entities = entities;
}
}