|
AndrusM wrote: Different objects can have same hash codes so has code can used only in hash algoritms which check for object eqality if hash codes match.
Yes, but that is not the problem here. Your problem is that you have two objects that contains the same data, but as the hash code is calculated based on the reference, they will still have different hash codes. As the hash codes are different, it will never compare the objects, as two objects with different hash codes by definition can not be equal.
AndrusM wrote: Is it simpler to use string as dictionary key and require that object key is string always ?
Will string comparison work by value in this sample ?
A string would work. Any type that implements GetHashCode based on the value instead of the reference would work.
---
single minded; short sighted; long gone;
|
|
|
|
|
Any type that implements GetHashCode based on the value instead of the reference would work.
It is sufficient to override GetHashCode() only ?
So I do'nt need to override Equals() method ?
Andrus
|
|
|
|
|
Any class that implements GetHashCode correctly also implements Equals.
---
single minded; short sighted; long gone;
|
|
|
|
|
I'm sorry I do'nt understand this.
Should I override ands re-impement Equals method in CacheKey buy comparing structure contents or not ?
Andrus
|
|
|
|
|
Yes.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hash codes are used for HashTables and Dictionaries, when a key is added the Hash code of the key is used to figure out which bucket the key should be stored in, this is how the searching for the key is speeded up.
http://msdn2.microsoft.com/en-us/library/4yh14awz.aspx[^]
Here is the exact code from the base class libary for when something is inserted into a dictionary:
int num = this.comparer.GetHashCode(key) & 0x7fffffff;
for (int i = this.buckets[num % this.buckets.Length]; i >= 0; i = this.entries[i].next)
AndrusM wrote: In this case I can use string as distionary key and I think string comparison works OK .
Yes, using a string would work very well, but I thought you wanted to use your custom Key class?
|
|
|
|
|
Thank you. Now I understand the need of GetHashKey() override.
However, this seems to be too complicated.
I'nt it simpler to create object key as string manually and use
Dictionary<string, BaseBusinessObject> Cache
instead.
Will string comparison work by value ?
Andrus
|
|
|
|
|
string comparison will work fine
|
|
|
|
|
Hello,
I'm working on a report loader and I'm facing a little problem. I get this error:
The modifier 'public' is not valid for this item.
The code is for making the credentials for viewing the report and is originally from a VB script. I've converted it with a lame online converter but I only get one and the same error at every
This is one of the methods:
<br />
<br />
namespace Reports<br />
{<br />
<br />
public class ReportServerConnection : IReportServerConnection<br />
{<br />
<br />
public bool Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials(ref System.Net.Cookie authCookie, ref string userName, ref string password, ref string authority)<br />
{<br />
authCookie = null;<br />
userName = null;<br />
password = null;<br />
authority = null;<br />
<br />
return false;<br />
}<br />
}<br />
}<br />
Anyone an idea? Thanku!
Stef
|
|
|
|
|
When explicitly implimenting an interface method you can't specify an access modifier as its always going to be public.
Remove the public from the method and it'll work fine.
|
|
|
|
|
Thank you that worked out fine
But now i'm getting a second error
<br />
namespace Reports<br />
{ <br />
[Serializable()]<br />
public abstract class ReportServerConnection : IReportServerConnection<br />
{<br />
bool Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials(ref System.Net.Cookie authCookie, ref string userName, ref string password, ref string authority)<br />
{<br />
authCookie = null;<br />
userName = null;<br />
password = null;<br />
authority = null;<br />
<br />
return false;<br />
}<br />
}<br />
}<br />
the error is :
'Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials' in explicit interface declaration is not a member of interface
and the second is:
<br />
'Reports.ReportServerConnection' does not implement interface member 'Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials(out System.Net.Cookie, out string, out string, out string)'<br />
any ideas? Thanku!!
Stef
|
|
|
|
|
If you change out to ref , the signature of the method changes. That means that you are trying to implement an overload of the method that does not exist.
---
single minded; short sighted; long gone;
|
|
|
|
|
hi
how to get the id of row to be updated on th click of button outside the grid view
|
|
|
|
|
One Post is enough. Within 5 minutes of time why are you creating the new thread for the same.
Regards,
Satips.
|
|
|
|
|
Get the ID from database and set the column as 'Hidden'. When clicking the row the ID will passed using script or in codebehind
|
|
|
|
|
Hello,
I`am using VS 2005 Express (C#) . Can someone show me simple code how to view a crystal report in application ?
I have a form FORM1 . Into this form I was add a Crystal Report viewer control 9 .
Then I have a report report.rpt whitch I need to add to view in this application.
Thank you for a help
Ivan
|
|
|
|
|
hi,
how to get the id of the row to be updated when the button is outside the grid view
|
|
|
|
|
If you want to do mass deletes or something like that I usually put a check box column. So I loop through the gridview to see which checkboxes are checked and then I know which rows to delete or whatever you are trying to do.
Hope that helps.
Ben
|
|
|
|
|
Hi,
is it possible to catch the handle of the Dr.Watson dump??? I will start mt.exe (Process.Start) from out a queue to embed a manifest on many .exe files. On some exe files mt.exe don't work and gives an Watson Window. I want to cancel the Watson window so my app don't still stand.
I can't catch an Exception on Process.Start();
Thanks
|
|
|
|
|
Im implementing undo option in ma image processing application for that I have made an array of 20 bitmaps
b4 every action I use the code to record the bitmap in array
<br />
if (bmpUNDOLEVEL[ucount] != null)
bmpUNDOLEVEL[ucount] = null;<br />
bmpUNDOLEVEL[ucount] = new Bitmap(origBitmap);<br />
ucount++;<br />
if (ucount == 20)<br />
ShiftUndoLevel();<br />
in undo button Im using
<br />
private void undoBtn_Click(object sender, EventArgs e)<br />
{<br />
if (ucount < 1)<br />
{<br />
origBitmap = null;<br />
origBitmap=new Bitmap( bmpUNDOLEVEL[0]);<br />
panel3.Invalidate();
ucount = 0;<br />
}<br />
else<br />
{<br />
origBitmap = null;<br />
origBitmap =new Bitmap( bmpUNDOLEVEL[ucount - 1]);
<br />
panel3.Invalidate();
ucount--;<br />
}<br />
if (ucount == 0)<br />
undoBtn.Enabled = false;<br />
}<br />
shiftundlevel shift the bitmaps once all 20 indexes of array is full;
public void ShiftUndoLevel()
{
ucount--;
bmpUNDOLEVEL[0].Dispose();
for (int i = 0; i < 19; i++)
bmpUNDOLEVEL[i] = bmpUNDOLEVEL[i + 1];
}
}
Can u figure out why is dis xception comin..........
|
|
|
|
|
ShiftUndoLevel() is wrong; check your for boundaries.
|
|
|
|
|
Luc Pattyn wrote: ShiftUndoLevel() is wrong; check your for boundaries.
well I have checked them I cant figure it out!!!!!!!!!
can u suggest anything!!!!!!!!!
|
|
|
|
|
Y u fl u nd to tlk in txtspk? It's very annoying.
Your code looks slightly suspect to me. Let's break it down, section by section:
if (bmpUNDOLEVEL[ucount] != null)
bmpUNDOLEVEL[ucount] = null;
bmpUNDOLEVEL[ucount] = new Bitmap(origBitmap);
ucount++;
if (ucount == 20)
ShiftUndoLevel(); Why are you doing it this way? Why do you add the record in and then reorder your undo stack? Surely you would be better off reordering the stack and then performing the bitmap assignment.
Second, I would recode your undo stack to use a List<Bitmap> instead of an array list. Then, your code would look something like this:
private List<Bitmap> bmpUndoLevel = new List<Bitmap>();
private void AddToUndo(Bitmap bmp)
{
if (ucount == 19)
ShiftUndoLevel();
else
ucount ++;
bmpUndoLevel.Add(bmp);
}
private void undoBtn_Click(object sender, EventArgs e)
{
if (ucount == 0) throw new ArgumentOutOfRangeException("ucount");
origBitmap = (Bitmap)bmpUndoLevel[--ucount];
panel3.Invalidate();
if (ucount == 0)
undoBtn.Enabled = false;
}
private void ShiftUndoLevel()
{
bmpUndoLevel.RemoveAt(0);
} Note that this isn't the complete code, but it should give you a starter for what to look at. BTW - repeatedly creating new Bitmaps is not the best way to manage them. Old ones need to be disposed.
|
|
|
|
|
Im robbins, and i need one help.
I have one list box filled with the form Names available in my project.
The user will select any one of the form he/she wants.
I want to display this selected form on a button click.
i dont want to use the select case statement, because the number of forms may vary in the future.
Please anyone gimme a solution to this issue.
thanks and regards,
Robbins
Robbins
|
|
|
|
|
hi,
I'm assuming you're using .NET 2.0
Use the List<> class like this.
<br />
List<Form> lstForms = new List<Form>();
Fill this list first:
lstForms.Add(new myForm());
Use this to fill you're listbox:
<br />
foreach(Form frm in lstForms)<br />
myListBox.Add(frm.Name);
The indexes of the list and listbox match now , opening the selected form would be:
lstForms[myListBox.SelectedIndex].Show(); //or showDialog();
If you are using .NET 1.1 use the arrayList class. You would have to cast the forms into object though.
Gideon
|
|
|
|