我是新来的,对 C# 有点缺乏经验。我一直在 MSDN 文档和 Google 中搜索,但找不到答案(我尝试尽可能笼统地表述):
我想在列表或数组中存储固定长度的有序整数序列,然后创建这些整数数组的数组。有谁知道如何计算不同整数数组的数量,以及应该使用哪些特定数据类型(列表、普通数组等)?我没有我一直在使用的确切代码,但这里有一些与我一直在尝试的类似的代码:
int[] set1 = {2, 56, 8};
int[] set2 = {8, 25, 90};
int[] set3 = {2, 56, 8};
var superset = new List<int[]>;
superset.Add(set1);
superset.Add(set2);
superset.Add(set3);
Console.Out.WriteLine(superset.Distinct().Count()); // would like this to output 2, but Distinct() doesn't seem to actually work and I would get 3
Run Code Online (Sandbox Code Playgroud) 假设我的表单中有一个String属性(表单不实现INotifyPropertyChanged).我还创建了一个BindingSource并将其DataSource设置为表单.然后我将一个文本框绑定到我的表单上的String属性(间接地,使用BindingSource).
问题1:当我在运行时更改文本框中的值时,为什么不在String属性的setter中命中断点?我认为将控件绑定到String属性将允许自动发生此方向的更新(GUI - >成员数据)
问题2:当GUI之外的其他内容更改String属性时,如何在另一个方向(成员数据 - > GUI)上触发更新?我不想实现INotifyPropertyChanged接口并将NotifyPropertyChanged添加到setter.我认为通过使用BindingSource的ResetBindings,我至少可以手动触发它
public partial class Form1 : Form
{
private String m_blah;
public String Blah
{
get
{
return m_blah;
}
set
{
m_blah = value;
}
}
public Form1()
{
InitializeComponent();
textBox1.DataBindings.Add(new Binding("Text", bindingSource1, "Blah",true,DataSourceUpdateMode.OnValidation));
}
private void button1_Click(object sender, EventArgs e)
{
Blah = "Clicked!";
this.bindingSource1.ResetBindings(false); //expecting the GUI to update and say "Clicked!"
}
}
Run Code Online (Sandbox Code Playgroud) c# ×2
2d ×1
data-binding ×1
distinct ×1
expo ×1
fetch ×1
permutation ×1
react-native ×1
winforms ×1