|
Hi,
I'm looking for some help implementing an issue i have.
main purpose is aggregating information from DB
I get data from a DB, and that table has 2 primary keys.
for each pair (primary key) i create an object that holds all the information, and after all the DB is read, i take each object and put its information in a different DB table.
I need to clarify that performance is very important, dealing with about 1milion rows every time.
The issue im having is how to hold that info. I tried using a Dictionary, the key being Pair<T,U> (simple object i created).
however, when using Dictionary.contains() didnt recognize 2 similar Pairs, and created a new 'similar' object instead of returning the one already existing.
I am not sure if I should implement Icomparable,
or maybe there is a different way altogether that might be better.
Thanks for your help
|
|
|
|
|
If the fields are primary keys in the DB, shouldn't they be guaranteed unique?
But anyway, IComparable isn't what you're looking for... That's to determine magnitudes, not equality. You want to implement IEquatable<T> ... Just try to make the implementation of that as efficient as possible.
|
|
|
|
|
Hi, sorry about the mixup, the fields are primary key in the table i'm putting the data in, not where im taking it from.
used: Dictionary<Pair<enum1,enum2>, myObj> _obj = new...
and in Pair<T,U> i implemented:' public override bool Equals(object obj)'.
will implementing IEquatable<T> be different from the Equals method?
Thanks for help
Edan
|
|
|
|
|
It's my understanding that the Dictionary looks first at the IEquatable<> interface... But I thought it looked at the basic Equals() too... Still, I would assume the generic version would be a bit faster, as it doesn't need to do any unboxing.
And you're using ContainsKey(), not Contains(), right?
|
|
|
|
|
yes, I tried ContainsKey(),
then i tried TryGetValue(). Both don't work.
i'm implement both equals (for object, and for IEquatable).
|
|
|
|
|
Could you paste the code you're using for IEquatable? Could be a problem there.
|
|
|
|
|
Due to lack of time, I decided to go with the .Net class KeyValuePair, even though the pure definition isn't what i wanted, it works
thanks for the help
|
|
|
|
|
Hi,
I have created a C# ActiveX control and I am trying to access its properties and methods using javascript exactly as described in this mini article http://www.c-sharpcorner.com/UploadFile/dsandor/ActiveXInNet11102005040748AM/ActiveXInNet.aspx
However, I fail to access any properties/methods of the control and the javascript does not display an error msg
Any Ideas? Thank you
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
Don't spam the forums Pick one and stick with it
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am not spamming, it just has two candidate locations, that's all.
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
|
This is often a difficult situation, but having two or more separate threads leads to a very fragmented site/knowledge base so pick the most suitable location for your question and leave it at that.
If, after a few days or more, it hasn't been answered (if it has then don't do this!) then by all means post in the other forum making it clear why you are cross posting and linking to the original thread so discussion can continue in the original location. This approach keeps things tidy and will avoid you getting flamed.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi all
I'm using this example Pretty IE Toolbar in C#[^] to make a toolbar that interface itself with an external validator.
I need to validate the page the user is currently viewing on the press of a button, but till now I was unable to get the original source of the file.
this code
HTMLDocument d = (HTMLDocument)this.Explorer.Document;<br />
d.documentElement.innerHTML;<br />
(where Explorer is WebBrowserClass) alters the source itself.
Is there a proper way to get the real downloaded source code (without the interference of javascript)
I cannot download the page using the url cause I would miss "form posts".
Thank you all
K.
|
|
|
|
|
I've also tried using a IPersistStreamInit, but the code i get is never the source code, for example an XML with an xsl return the transformed HTML code and not the xml source.
How can I get the raw source?
Thank You
K.
|
|
|
|
|
how to convert string to binary.
example a = 01100001
|
|
|
|
|
Your example is already binary; try rewording your question. Alternatively you could just use the Int32.TryParse()[^] method.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
String <-> Binary is easy:
Int to Binary String:
string s = Convert.ToString(myInt, 2);
Binary string to int:
int i = Convert.ToString(myString, 2);
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
i can some speak english...
i want to convert string to binary.
example;
string myString = stringToBinary("a"); //return value will be 01100001
string stringToBinary(string str)
{
.....
.....
.....
}
|
|
|
|
|
You can cast char s to int s, an other post tells you what to do with the resulting int
|
|
|
|
|
Hi,
let me put a couple of things straight first: there are no decimal numbers, no hexadecimal numbers, no binary numbers, there are just numbers. A number is a number, it does not have a base.
It is only when a number gets represented by a string (maybe because it gets shown to the user, or input by the user) that it becomes a decimal, hexadecimal, binary, or whatever representation of that number.
And here are some typical operations:
int num=20;
string decimal1=num.ToString();
string decimal2=num.ToString("D5");
Console.WriteLine("decimal representation: "+decimal1);
string hex4=num.ToString("X4");
Console.WriteLine("hexdecimal representation: "+hex4);
int val16;
int32.TryParse(hex4, NumberStyles.Hexadecimal, null, out val16);
Console.WriteLine("The value of hex "+hex4+" is "+val16);
string binary=Convert.ToString(num, 2);
int val2=Convert.ToInt32(binary, 2);
Console.WriteLine("The value of binary "+binary+" is "+val2);
string octal=Convert.ToString(num, 8);
int val8=Convert.ToInt32(binary, 8);
Console.WriteLine("The value of octal"+octal+" is "+val8);
|
|
|
|
|
i try your code
string binary = Convert.ToString(Encoding.UTF8.GetBytes("a")[0], 2);
--------------------
//binary value is "1100001"
//but "1100001" is 7 bits. its must be 8 bit. must be value of binary "01100001".
|
|
|
|
|
sure, when you mean "eight" do you write "0000000008" or "8"? it isn't because a 32-bit integer could hold up to 10 digits that you must prefix all those zeroes, is it? Not in decimal, not in hex, not in octal, not in binary.
If you want something prefixed, use string.PadLeft()
FYI: There is a shortcut for hexadecimal, the format specifier "X4" enforces at least four digits, prefixing zeroes as necessary. However there is no binary or octal format specifier in .NET
|
|
|
|
|
Having just seen his reply to you, I think you are going to have fun with this, Luc! He seems to be saying that leading zeros are significant...
Why do they let these people loose with a keyboard?
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I do not know English fully. so I could not understand the full last message.
Thank you for your reply
|
|
|
|
|
Don't worry, it is Friday, for some people it is time for a spirit shift.
|
|
|
|