|
Something like this would do the trick.
String oldString = "I have a Computer Box on my desk";
String searchTerm = "computer box";
String replacement = "Computer System";
int idx = oldString.IndexOf(searchTerm, StringComparison.CurrentCultureIgnoreCase);
if (idx != -1) {
String frontEnd = oldString.Substring(0, idx);
String backEnd = oldString.Substring(idx + searchTerm.Length);
String newString = frontEnd + replacement + backEnd;
Console.WriteLine(oldString);
Console.WriteLine(newString);
} else {
Console.WriteLine("Search term not found: {0}", searchTerm);
}
Alan.
|
|
|
|
|
I want to store raw data in an array:
byte[] byteArray = new byte[]{0x00,0x01,0x02};
This works, but it is space-inefficient because every byte will consume five bytes of harddisk space. Can I somehow make every byte only consume one byte of harddisk space?
|
|
|
|
|
What makes you think every byte will consume 5 bytes of space?
There will be some overhead for the array object, but beyond that a byte is a byte.
Simon
|
|
|
|
|
Thanks for your post. Please note that it is the size of the .cs file I want to reduce, not the .exe file.
|
|
|
|
|
Oh...Right....I get what you mean...
Why on earth do you care about the size of the .cs file?
You can just use numbers if it is really that important to you
byte[] byteArray = new byte[] { 0, 1, 2 };
I can't think of any reason why you would need to do this though. You don't go deleting all the spaces and carriage returns to save space do you?
Simon
|
|
|
|
|
Thanks for your reply. I have large arrays in my software. I'd rather have a 4 MByte file than a 20 MByte file.
|
|
|
|
|
arnold_w wrote: 4 MByte
Frick, that's a lot of constant data.
Well, like Luc said, I think I'd load it from a data file. But it depends a bit on your requirements, if speed is critical, you may find loading it from a data file is slower, not sure though, and it probably doesn't make a lot of difference. I'd probably test it before deciding.
Simon
|
|
|
|
|
|
You could put each bunch of data in its own class and therefore in its own file.
You could use partial classes to split the parts of one class into many files.
|
|
|
|
|
Hi,
two solutions:
1. inside the cs file, you don't need to use hex notation, and you don't
need leading zeroes, so each value could take 2 to 4 characters (1 to 3 digits
and a comma), depending on value.
2. to get to highest file efficiency (and assuming there is several KB of data)
use a separate binary data file and add some code to load it into the
byte array at app launch.
|
|
|
|
|
|
If you want to store binary data in an assembly at design time you can always add a binary resource to the project.
|
|
|
|
|
Thanks y'all for your posts and suggestions.
|
|
|
|
|
Hai friends,
Iam creating an ASP.Net application. Here i wants to upload data to an excel. I wont like to getting the excel file using normal method. Rather, how can i implememt late binding concept in c# to activate the excel...
Thanks in advance
Praji
|
|
|
|
|
I have a pictureBox control, I want it to appear horizontal and vertical bar when the size of image over its size? Please let me know how to do that!
And I want it zoom its image when I scroll the middle of my mouse. I don't know how to do that.
Best regards
|
|
|
|
|
Hi all,
I have a C# application and I want to develop an installation package in C# which simply copies some files from original CD and installs .Net Framework, Crystal Report and ... but my installation package needs dotnetfx itself!!! Oh, it needs Windows Installer too, right?
InstallShield? Maybe, but I know nothing about it and I have to learn IS but I have no time, maybe another day...
Is there another way to run my installation package?
Thanks
While (true) { Human.isLearnable = true; }
|
|
|
|
|
Hi,
have a look at at the Windows Installer XML (WiX) toolset (http://wix.sourceforge.net/[^]. It's a wrapper for the Windows Installer. Simple to learn and results can be achieved in nearly no time.
|
|
|
|
|
Hi,
I am using VS 2005, SQL Server 2005 in windows XP. I wanted to used all these in windows vista
anybody please tell me which windows version is better for .Net developers.
Ramana
|
|
|
|
|
Don't Repost
Sathesh.
Blessed is the season which engages the whole world in a conspiracy of love.
|
|
|
|
|
Ramana. G.V wrote: Which windows vista version is better for .net developer.
The XP one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Don't cross-post.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Any Vista edition except the starter edition.
Pick the version that has the features you need.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Don't cross post.
"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
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I am populating a control with data in a loop...
The problem is that while the loop is taking place and because it takes a long time to finish the loop, the UI freezes.
Can you show me a simple example where I populate a control with many items but at the same time I can see the data being added to the listbox and so the UI does not freeze?
I know this is to do with threads but I have not been able to find a simple example to implement.
Thanks
|
|
|
|
|
You can use BackGroundWorker class.
|
|
|
|