|
I had a question about StringBuilder
What's the equel of Substring method in StringBuilder ?
|
|
|
|
|
Don't think there is one. But try calling the ToString() method and then the SubString() method on the returned string object.
StringBuilder s = new StringBuilder();
s.Append("foo");
string a = s.ToString().SubString(0,1);
|
|
|
|
|
Wouldn't use it if there was one (which there isn't, I don't think)!
Try this, if you are most comfortable with strings.
static void func(ref string bits)
{
StringBuilder sb = new StringBuilder();
char Out;
foreach (char c in bits)
{
if (RANDOM_NUM < MUTATION_RATE)
{
if (c == '1')
Out = '0';
else
Out = '1';
}
else
{
Out = c;
}
sb.Append(Out);
}
bits = sb.ToString();
}
You could use a System.Collections.BitArray, but it may be a little heavy-duty for what you are trying to do. Probably the proper way to do it though!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Strings are immutable. This means you can't change them once they have been created.
You can access the individual characters like you are doing, but you can't set them to new values. (Don't be fooled into thinking you can modify strings by doing concatenation and stuff like that. Every string operation that looks like it is making a change is actually creating a new string object so if you do it a lot it can get quite slow)
Take a look at the System.Collections.BitArray[^] class instead, it might be better suited to what you are doing.
Simon
|
|
|
|
|
While strings are meant to be immutable, you can cheat with pointers. It's dangerous though, with interned strings etc. So just don't. But that doesn't mean it's impossible.
|
|
|
|
|
Howdy,
I'm using this.Refresh() method in the Button_Click event to refresh the machine, but this only works for the form in particular. It doesn't seem to refresh the system, rather it seems like as if the form is getting refreshed up.
Any way through which I can refresh the machine from two to three times, on a single button click? And is it possible to send the F5 key in oder to refresh?
plz help!
i_w32_app.
|
|
|
|
|
What are you trying to achieve?
this.Refresh() just invalidates the object (in this case the form your button is on) and issues paint messages for it and child controls.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
Lemme clarify my question. I am trying to refresh the machine after a specific task has been accmplished.
Like:
private void button1_Click(object sender, EventArgs e)
{
.........................................................
.........................................................
}
Help
|
|
|
|
|
Do you mean you want to refresh the entire view in the monitor?
If so, you'll have to use some PInvoke and at a minimum, get the desktop's handle and call InvalidateRect or UpdateWindow. You may need to do this for every open window too.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Is there some comprehensive way to this? I mean to say that this is quite difficult.
PS: I only want to refresh the desktop.
What about this:
private void Button1_Click(object sender, System.EventArgs e) {
SendKeys.Send("{ENTER}");
}
Please let me know.
|
|
|
|
|
It seems the easiest way to do this is to make the shell think file associations have changed. When it does, it redraws the desktop. Not sure how 'expensive' this is - but it works.
SHChangeNotify(SHCNE_ASSOCCHANGED, 0, 0, 0);
[DllImport("shell32.dll")]
static extern void SHChangeNotify(uint wEventId, uint uFlags, uint dwItem1, uint dwItem2);
const uint SHCNE_ASSOCCHANGED = 0x08000000;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Invalid_Win32_app. wrote: I am trying to refresh the machine
What exactly do you mean by "refresh the machine"? Do you mean reboot?
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
molesworth wrote: What exactly do you mean by "refresh the machine"? Do you mean reboot?
Not Reboot, I am just trying to refresh the PC, like we do by right-clicking on an empty space on the desktop and clicking on the Refresh option from the menu display. Thats what I want to do.
|
|
|
|
|
Your request is totally dumb! refresh the system doesn't mean anything.
Refresh your desktop doesn't mean to refresh your system...
Try to be more explicit Rajdeep
|
|
|
|
|
I think this should do:
private void button1_Click(object sender, EventArgs e)
{
SendKeys.Send("{F5}");
}
What do you say?
PS: How did you know that I am Rajdeep?
|
|
|
|
|
Invalid_Win32_app. wrote: PS: How did you know that I am Rajdeep?
You can see the last 200 messages somebody has posted.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Your level of stupidity is unique.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hey Rajdeep.NET, did you think that we wouldn't notice if you changed your name?
You're still asking strange questions.
Now I don't really know about this refresh thing, this is not normally something you even need to consider doing. Why do you even need to do this?
Anyway, I'd look into sending a F5 keypress, like you suggested..
|
|
|
|
|
Ok Ok!!! Chill now, I haven't asked any strange question this time.
|
|
|
|
|
y do u frequently change you name.... do you think that we are fools here...
Padmanabhan
|
|
|
|
|
Invalid_Win32_app. wrote: Ok Ok!!! Chill now, I haven't asked any strange question this time.
This question is very strange, to refresh your system, you need to reboot your PC (after changing registery keys...). How does windows refreshing itself after an update? It just reboot..
To press F5 on tour desktop only refresh the 'explorer.exe' program, but not your system who's loaded on startup. To press F5 on your application will do anything not even refresh your 'explorer' application.
Try to discover the basics of windows before trying to hack it...
|
|
|
|
|
now that guy has changed his name to x+y=xy?!
some one has to take care of his activities....
Padmanabhan
|
|
|
|
|
Not all are fools, rather than you!
|
|
|
|
|
sit and recollect all your posts and the replies then you will know who is a fool....MR.XYZ
Padmanabhan
|
|
|
|
|
Hello Friends
How to get list of files and folders from web server using http protocol?
|
|
|
|