|
I provide another method that you can call to know the progress of the task started.
|
|
|
|
|
I have seen some codes as are shown bleow, although they works fine but i am asked to use equal() function with strings. What's the difference then.
string str="aa";
if(str=="aa")
{
}
|
|
|
|
|
I think Equals function compares the reference not the value itself.
|
|
|
|
|
No.
From Object Browser...
Determines whether this instance of System.String and a specified object, which must also be a System.String object, have the same value.
Dave
|
|
|
|
|
If you use Equals() you can specify the culture (your own, a preset or none at all) used for the string comparison.
You can also compare with an object. Consider this example:
ListBox listBox = new ListBox();
listBox.Items.Add("a");
string x = "a";
Console.WriteLine(x.Equals(listBox.Items[0]));
Dave
|
|
|
|
|
netJP12L wrote: string str="aa";
if(str=="aa")
{
}
This is equal to
string str="aa";
if(str.Equals("aa")){
} When you use str == "aa" , string class calls the Equals() method to do the comparison. Only advantage I can see if you use Equals explicitly is supplying the StringComparison enum.
I prefer to use string.Compare to compare strings.
|
|
|
|
|
All,
I am attempting to write a new Remote Registry key Value string, but I keep receiving a "Cannot write to the registry key" exception. I have full access to the remote key and have set that access (as an extra measure) inside my program. Below is the code I an attempting to use. I can read the value fine, but cannot edit it.
Thoughts?
bool SetRegKey(String hostname, String strPrimaryUserGroup)<br />
{<br />
String strBaseKey = "Software\\Agent";<br />
RegistryKey environmentKey = RegistryKey.OpenRemoteBaseKey(<br />
RegistryHive.LocalMachine, hostname).OpenSubKey(<br />
strBaseKey);<br />
String PUGValue = environmentKey.GetValue("PrimaryUserGroups").ToString();<br />
if (PUGValue != strPrimaryUserGroup)<br />
{<br />
environmentKey.SetValue("PrimaryUserGroups", strPrimaryUserGroup);<br />
}<br />
return false;<br />
}
|
|
|
|
|
Hi, I've been trying to get a list of module names of local processes on my box but I got access denied in the attempt. This issue happen with every high privileged process ie: smss, svchost, winlogon, ... I've tried google it but without success any hint on that ? Btw I'm using VS 2005 on Vista.
sh*t
|
|
|
|
|
Hello,
VS 2008
I have typed dataset and have added a single data table named dsMissedCalls.xsd and dtMissedCalls.
I would like to save some missed calls for my application. The table is very small not more than 10 rows.
Example. dtMissedCalls(ID, Caller, DateAndTime)
I have created a XML file, and I would like the xml file to have the schema of the typed dataset (dsMissedCalls.xsd).
Before when I have been creating xml file. I would add a new xml file. Then click the "Create Schema" button. That would creaet the schema for the xml file. However, as I have created a typed dataset that already has a schema. The question is. How do I get my xml file to relate to that schema?
So basically I have created a typed dataSet and would like to save added rows to the xml file.
The code below works, but I want to xml to use the dataset schema.
Many thanks for help with this confusing question,
<br />
DataRow row;<br />
row = ds.Tables[0].NewRow();<br />
row["Caller"] = callersName;<br />
row["DateTime"] = DateTime.Now.ToShortDateString();<br />
<br />
ds.Tables[0].Rows.Add(row);<br />
ds.WriteXml(missedCallsXML, XmlWriteMode.DiffGram);<br />
|
|
|
|
|
Hi,
I have used the picture box to draw an image on the screen. Its loading perfectly, now I want to draw over some parts of the image, with rectangles and lines.
I tried to draw on the picture box by doing the following but nothing shows up?
How can I go about doing this.
Graphics g = pictureBox1.CreateGraphics();
SolidBrush solidBrush = new SolidBrush(Color.Blue);
g.FillRectangle(solidBrush, 0, 0, 100, 100);
Any help would be greatly appreciated
|
|
|
|
|
You cannot simply draw a line or rectangle on top the image. They are drawn behind the image. You need to make them a control and set the foreground or background property.
|
|
|
|
|
"Graphics g = pictureBox1.CreateGraphics();"
That is a bad idea unless you're drawing something you want to erase, like a rubber band. Painting should take place in the paint event. And, at this point, you should just draw your bitmap in the paint event, then draw on it.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I'm would to find out if anyone has an example of spying on another app like the Managed Spy[^] but being able to retrieve the selected row and/or the text in the various columns of that row. Is it possible in .NET 2.0?
I would especially appreciate an example of MFC C++ spying on .NET 2.0 code and being able to get the DataGridView text.
Thanks,
|
|
|
|
|
My project is written by C++, now I want to change it to .NET platform, I have two choices, C# or C++/CLI, choose C# means rewrite all of the code, choose C++/CLI means part rewrite, and it's flexible
But I'm warry about three points:
1.The grammar of C++/CLI is surprising, what is the C++/CLI like? C++? C#? a new language?
2.The flexibility of C++/CLI is interesting, but may not good to the project leader, if the programmer write some pure c++ code and cause some abnormal memory accessing, it's hard to find them out. Who can guarantee that his programmers are all good enough?
3.After change to C++/CLI, the workload of refactoring may not lower than rewriting
So, it seems that I should use C#? Who can give me some ideas? Thanks in advance
|
|
|
|
|
C# would be the better way to go. I was brought up with C++, went over to C# since I also worked with Java and there are similarities. When C++/CLI came about, I was too hooked on C#. Compare the number of posts in the C# forum here versus the C++/CLI forum...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
In my opinion you should try to stay away from c++/cli.
Either choose c++ or C# or like i do: Use C# for gui and stay with c++ for internal processing.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
Yes, the WPF attacked me, I want to use it to the GUI. thanks for your advice
|
|
|
|
|
hello..
I have one form with datagrid on it. when i click the button on that form, it shows another form on which i made updating database using SQLCommand. When I turn to the first form, the datagrid isn't updated...It is updated only when I close application and start it again- then i see the changes..
I also have this line of code after I close the second form: DataGrid.Refresh()
What should I do?
|
|
|
|
|
Is it ok that i do this after i close the second form:
dataSet.Clear();
dataAdapter.Fill(dataSet);
then, it will work. But, is it ok this, because in the Load method on first form I already set dataSet and fill adapter? or it isn't matter at all?
|
|
|
|
|
hi all does anyone know how to convert the following js into c# ?
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which is contained in the following loop (for clarity):
for(var c:Number = 0; c < src.length; c ++){
if(cc>=i) {
cc = 0;
}
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
cc++;
}
I've searched and found the equivalent for both but dont seem to be able to put it together, it should be something like this in c#:
my_str += new String(new char[]{(Int32)Data[c] ^ keys[cc]});
but that obviously fails and im just confusing myself now. any pointer very very much appreciated.
keys is already converted into an array of ASCII codes and Data is a string at present, i was thinking I should convert it into an array of ASCII codes as well.....
thank you
tim
|
|
|
|
|
ignore
was having one of those moments when you cant see the woods for the trees (or whatever!)
my_str += (char)(letters[c] ^ keys[cc]);
does the job after creating the letters array using (Int32)input[i] in a for loop
thanks
anyway.
t
|
|
|
|
|
You are on the right track, you just need a few more parentheses so that you are casting just the character instead the entire result.
Don't use += to build the string, put all the characters in an array and create a string from that.
char[] chars = new char[Data.Length];
for (int c = 0; c < Data.Length; c++) {
chars[c] = (char)(((int)Data[c]) ^ keys[cc++ % i]);
}
string my_str = new string(chars);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi guffa
whats the difference between creating an array(then string) or building the string as we go. I dont mean that in a rude way I'm intrigued as they produce two different results from what *should* be the same string or is it the char creation that differs the result ?
tim
|
|
|
|
|
The difference is that if you use += to create the string, you are creating every intermediate string as a separate object.
If your code creates the string "This is a test", it will also have created the strings "T", "Th", "Thi", "This", "This ", "This i", "This is", "This is ", "This is a", "This is a ", "This is a t", "This is a te" and "This is a tes".
Strings in .NET are immutable. When you use the += operator, you are actually creating a new string object every time, copying the data from the original string.
For very short strings, this is not a big problem, but it quickly gets bad. To create a 100 character string, you will have created 10 kB of strings. To create a 1000 character string, you will have created 1 MB of strings.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi
thanks for that, thats very interesting and something I didn't realise.
but... strangely enough that must be the way that javascript handles it (i think *gulp*) as the original way I was doing it :
c#
my_str += (char)(letters[c] ^ keys[cc]);
produces exactly the same result as:
js
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which was(after to base64 encoding for transport(the unencoded isn't really printable)):
OhFBBxQWEBFLGgsEHgoVRBwSEAYCCw==
and yours produced:
OhhBBh4eCRNPEQkMBQQVVRgaHggBBQ==
I was doing this as an little encryption thing between flash and .net as i couldn't find anything that was compatible, I tried many different ones (rijndael, TEA etc) but all the flash conversions of them produced completely different results from the c# end and I was tearing my hair out trying to do my own conversions of them so I thought i would write a simple (obviously not that strong - but it doesnt need to be super difficult) bit of encryption that i could rewrite in javascript(for the .as files in flash and also for php etc) that would suffice.
but... like you say the larger the string then the larger the problem(or at least load) so now i'm wondering if theres a way to reproduce what you've said in js - this isn't a problem for what I'm doing now but it would be nice to have a better model in place for future.
something for me over the weekend
thanks for your replies and if you have any thoughts I'd be really interested to hear them.
tim
<edit>
i suppose in js i would just create an array and then use push to add them in and then create the string...but i still don't get why it produces different results from what *should* be the same string...hmmmm time for some script outputting...
modified on Friday, July 4, 2008 8:33 PM
|
|
|
|