Click here to Skip to main content
13,446,281 members (33,514 online)
Rate this:
Please Sign up or sign in to vote.
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 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)
  (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)

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
Posted 25-Apr-12 4:42am
SAKryukov 25-Apr-12 11:17am
Why typing the algorithm here if it is more or less apparent that you did not understand it, otherwise you would at least explained the symbols introduced. You use the TOPOLOGICAL-SORT function as if it was already defined somewhere, so this is not an algorithm of topological sort, so what it is? I am not sure you know yourself.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The collection supporting uniqueness is, for example System.Collections.Generic.Dictionary<KEY, VALUE>; please see:[^].

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:[^].

Now, about ArrayList. First, there is no need to use it for any new development. Instead, use System.Collections.Generic.List<T>:[^].

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:[^],[^].

VJ Reddy 25-Apr-12 12:02pm
Good answer. 5!
SAKryukov 25-Apr-12 12:07pm
Thank you, VJ.
Member 8845505 27-Apr-12 4:49am
Thanks you u answer it very well I tahnk you and may GOD bless U.
SAKryukov 27-Apr-12 10:13am
You are very welcome.
Good luck, call again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01-2016 | 2.8.180314.2 | Last Updated 25 Apr 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100