|
Hi,
you can also call Hashtable.Remove(key) before calling Hashtable.Add(key,val) ; there is no need to test for existence first.
The same principle applies to the generic Dictionary<T> class.
BTW:And it is similar to removing-then-adding a delegate to an event.
|
|
|
|
|
Thanks for replays.
Actually I got data pair like One 2 and so on. I want to store each of them. If I found a duplicate one value(number) should be updated. Then later I want to take all of them to make a string.
Say my data like this.
One 3
Two 5
One 7
Then the string should be,
One 7 Two 5
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi,
you can add/replace key-value pairs as shown before.
for a Dictionary<(TKey, TValue> you can enumerate all keys
with foreach(TKey key in Dictionary.Keys) {...}
and similar stuff goes for old Hashtables.
WARNING: dictionaries, hashtables don't preserve chronology, so there is no guarantee that "One 2" will come first in the enumeration. If you insist on having that, you will need a different approach,
most likely a combination of a List and a Dictionary (a List preserves order unless you instruct it to drop the order, e.g. by sorting).
|
|
|
|
|
Use a generic Dictionary(TKey,TValue) . It has a ContainsKey method which will return TRUE if the key supplied exists. If it exist, just update the value instead of adding new one.
|
|
|
|
|
hello
How can u think of storing the different value with the same "Key"
As u mentioned "One"====> the key ... how it can be repeated under the same instance
see link
http://www.c-sharpcorner.com/UploadFile/mahesh/Hashtable11082005171748PM/Hashtable.aspx?ArticleID=6880f0d4-acc6-402c-b632-d2e353e98e62
|
|
|
|
|
Make a custom function for it which check whether this entry is already there or not by
hshTable.ContainsKey("one")
if it there then remove it as
hshTable.Remove("one");
and again add as
hshTable.Add("One", 6);
Cheers!!
Brij
|
|
|
|
|
Hi,
create a 5-line method to do what a single statement can do? I suggest you (re)read Giorgi's and my earlier replies.
|
|
|
|
|
Hi!
It quite simple
If Key Not Exists Keep on Adding
Else If Exists RemoveKey and then Add
Thanks!
Develop2Program & Program2Develop
|
|
|
|
|
ohhhhhhh
wht an answer u ..... made out ..........
hoooooooooooo
fantastic 
|
|
|
|
|
ok
Develop2Program & Program2Develop
|
|
|
|
|
OK
Program2Develop & Develop2Program
|
|
|
|
|
I think it is easy to solve your problem with many ways:
e.g:
use the combination of your key and value as new key;
|
|
|
|
|
Hello , there.
I saw the C# sample codes its a Windows Live ID for Client DLL.
So I thought I could change delphi2007 win32 code.
I tried to use a auto making import feature.
Therefore component -> .net assembly import -> create unit
But I could not use functions well becasue there are just inferfaces and
connecting functions.
Can't Client DLL assembly .net dll of Window Live ID released use other language for win32?
Can i use this .net dll or not?
Thanks. Have nice days.
Thank you
|
|
|
|
|
Hello , there.
Whom
|
|
|
|
|
Hi,
I HAVE FIFTHY RECORD IN MY TABLE...
I HAVE TO SHOW IT IN DATAGRIDVIEW MULTIPLE OF 10'S...
FIRST 10,SECOND 10....
|
|
|
|
|
You probably already know how to do this, it's just because your caps lock key is stuck that the code won't compile....
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
HOW WILL YOU DO THAT?
AND WHY ONLY 50?
|
|
|
|
|
i will do this using dataadaptor....
a have lot of records in that....
so ihave to see it in a particular format....(10,10,10)
|
|
|
|
|
Hi,
I’ve define a panel on my from and define the panel dock as none, and increase the panel height each time I add new item at the button of the panel, once the panel size exceed form size, the form create vertical scroll bar and its great.
The problem is that I can use the mouse in order to scroll down the panel but the keyboard is not working such as page up, page down, up key and down key
Any idea,
I look at the form and panel property and I didn’t find anything that could help
Thanks,
Ronen
|
|
|
|
|
If you have a scroll bar and the control has focus, then it will either just work ( which would have been my guess ), or you need to write code to handle it ( which seems odd to me, but if it doesn't work at all, that's probably the solution ).
Does the control have focus when you press the keys ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yes,
Itry to use it option
at the panel_paint func
I write
if(panel1.CanFocus)
{
panel1.Focus();
}
and it still doesn't work
Ronen
|
|
|
|
|
Hi,
I was trying to Automate MS Excel, I want to check the validity of a COM Object in C#. For Instance, after releasing a sheet Object using "Marshal.ReleaseComObject(m_oSheets)" Sheet object is not equal to null. How to check a COM Object is valid or not.
Thanks in Advance.
Excel._Application m_oApplication;
Excel.Workbooks m_oWorkBooks;
Excel._Workbook m_oWorkBook;
Excel.Sheets m_oSheets;
Excel._Worksheet m_oWorkSheet;
Marshal.ReleaseComObject(m_oSheets);
if (m_oSheets == null)
{
......
}
|
|
|
|
|
KarthikonIT wrote: after releasing a sheet Object using "Marshal.ReleaseComObject(m_oSheets)" Sheet object is not equal to null.
Do the docs say it will be null, or is it your job to set it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Docs says it will be null for C# Object but it is not null even after releasing the Excel Object with the following code "Marshal.ReleaseComObject(m_oSheets)". I don't want to set it to null. My question is "How do i know the particular Excel Object is valid or not".
Thanks for response
|
|
|
|