如何在列表框中没有相同的名称 [英] How can i do to don't have the same name in my Listbox

查看:75
本文介绍了如何在列表框中没有相同的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

盖伊,

请我有3个请求.

1.我真的不知道如何在C#中阻止列表框,以便当用户在TextBox中给出相同的名称时,它会拒绝它.在C#中

2.我的第二个请求是关于ArrayList.

-我可以在我的Arraylist中毫无问题地插入偶数或动作列表(例如:StandUP,Sleep,Eat,Work,answer),但是我不知道如何在不同动作之间建立链接或关系.我要求在大学里说他谈论Tologic Sort().我对此一无所知.

请我找到一个关于它的算法.但是用C#语言进行转换对我来说是如此困难.
这是Algorithme

Hey Guy,

please i have 3 request.

1 .I don''t really know how i can do in C# to block my listbox so that when the User gives the same name in TextBox that it reject it.in C#

2. My second request is about a ArrayList.

-I have without problem insert a list of evenement or action(for example: StandUP,Sleep,Eat,Work, answer ) in my Arraylist but i don''t know how to make a Link or Relation between a diifferent action. I ask to sombody in the college he speak about a Tological Sort(). I don''t no one thing about it.

Please I found one algorithm about it. But to transform it in C# language is so difficult for me.
Here is the Algorithme

Calculate network(working-packages A = {wP1..., wPn}, dependence Dep ⊂ A × A)
  A' ← TOPOLOGICAL-SORT(A,Dep)
  (now all dependent WPs stand behind their(her) presuppositions)
  for WP ∈ A' (in accordance with topological order)
  doif WP is the first task   
    then [ EarliestBegin(WP) ← 0
       else [ EarliestBegin(WP) ← max X ∈ WP mit (X,WP) ∈ Dep : EarliestEnds(X)
     ⌊ EarliestEnds(WP) ← EarliestBegin(WP) + Duration(WP)
  for WP ∈ A' (in accordance with reverse topological order)
  do ⌈ if WP is Last Task      
    then [ LaterEnds(WP) ← maximum project duration (or  EarliestEnds(WP))
       else [ LaterEnds(WP) ← min X ∈ WP mit (WP,X) ∈ Dep : LaterBegin(X)
     ⌊ LaterBegin(WP) ← LaterEnd(WP) - Duration(WP)






某人可以帮助我理解它,也许请向我解释不同的步骤.我将首先为自己尝试的代码.

请问我如何理解它
在此先感谢
Leonce






Can someboy Help me to understand it maybe to explain me the different step please. the code i will try firstly for myself.

Please how can i understand interpretate it
thanks in advance
Leonce

推荐答案

支持唯一性的集合为例如System.Collections.Generic.Dictionary<KEY, VALUE>;请参阅:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx [ ^ ].

方法TryGetValue可以使您获得通过某些键索引的值或信息(如果该信息已在字典中);而ContainsKey方法(如果非常快,复杂度接近O(1))和ContainsValue方法(可能很慢)将检查其中的内容.您可以将所有值与控件中的值并行,并在将其添加到UI之前检查/添加新值.

查看其他通用集合类型,并阅读每种类型的MSDN帮助页面,以了解何时使用一种或另一种:
http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx [ ^ ].

现在,关于ArrayList.首先,无需将其用于任何新开发.而是使用System.Collections.Generic.List<T>:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx [ ^ ].

当引入泛型时,.NET Framework v.2.0中所有过时的非专业化非泛型集合类型都已过时.如果它们已经在经过完全调试的旧设备中工作,它们会很好,但是在新的开发中使用then绝对没有意义,因为它们需要较少的安全类型转换.发明了泛型以消除那些类型转换.如果您不太熟悉泛型,那么也许这是现在首先要了解的内容.

但是-列表类型不会帮助您.关于使用列表表示关系的问题确实没有任何意义.列表只能代表一个列表.您必须使用笛卡尔正方形对象及其子集,这些对象代表任意有限图或关系.作为表示笛卡尔正方形A x A的最简单方法,您可以简单地使用数组[N, N],其中N表示集合中的许多元素,例如一组图所示的元素.在我的文章中,我或多或少地对图形和关系的表示做了全面的解释:
​​枚举类型不枚举!解决.NET和语言限制 [ ^ ].

请参见"3.6直角坐标系"部分:
枚举类型不枚举!解决.NET和语言限制 [ 3.6.笛卡尔正方形].

另请参见:
http://en.wikipedia.org/wiki/Cartesian_product [ http://en.wikipedia.org/wiki/Binary_relation [
The collection supporting uniqueness is, for example System.Collections.Generic.Dictionary<KEY, VALUE>; please see:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^].

The method TryGetValue can make you get a value indexed by some key or an information if it is already in a dictionary; and the methods ContainsKey (this one if very fast, of nearly O(1) complexity) and ContainsValue (can be slow) will check up what is there. You can keep all your values in parallel with the values in the control and check/add new values before adding them to UI.

Look at other generic collection types and read MSDN help pages on each to know when to use one or another:
http://msdn.microsoft.com/en-us/library/0sbxh9x2.aspx[^].

Now, about ArrayList. First, there is no need to use it for any new development. Instead, use System.Collections.Generic.List<T>:
http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx[^].

All non-specialized non-generic collection types were rendered obsolete in the .NET Framework v.2.0, when generics were introduced. They are fine if they already work in fully-debugged legacy units, but using then in new development makes absolutely no sense, as they require less safe type casting. Generics were invented to eliminate those type casts. If you are not well familiar with generics, perhaps this is the first thing to read about right now.

But — the list type won''t help you. The question about using the list to represent relations makes no sense, really. A list can represent only a list. You have to work with the Cartesian Square objects and the subsets of it which represent an arbitrary finite graph or a relation. As a simplest way to represent a Cartesian Square A x A you could simple use an array [N, N], where N represents a number of elements in the set, such as a set of the noted of a graph. I have more or less comprehensive explanation of representation of graphs and relations in my article:
Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^].

Please see the section "3.6 Cartesian Square":
Enumeration Types do not Enumerate! Working around .NET and Language Limitations [3.6. Cartesian Square].

See also:
http://en.wikipedia.org/wiki/Cartesian_product[^],
http://en.wikipedia.org/wiki/Binary_relation[^].

—SA


这篇关于如何在列表框中没有相同的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆