|
Split the string by semicolon:
string input = "1 2 3;4 5 6;7 8 9";<br />
string[] rows = input.Split(';');
Now you have an array with three records. Create an array of string arrays to store the final result:
string[][] matrix = new string[rows.Length][];
Now split each row by space to get an array, and put it in the matrix:
for (int i=0; i<rows.Length; i++) matrix[i] = rows[i].Split(' ');
---
b { font-weight: normal; }
|
|
|
|
|
Thanks..solves my problem. u exactly got into the root of the problem.
|
|
|
|
|
Note though that the code does not check if the matrix is square. It will happily turn a string like "1;2 3 4 5;;6;7;8 9" into arrays without complaining.
---
b { font-weight: normal; }
|
|
|
|
|
Hi all,
I've started coding a windows form without the designer and suddenly I needed to set one of this property. Then I took a look at the code and saw that the designer added a function InitializeComponent() and did the setting of the property there. Couldn't the property be set in the Form's constructor? And where can I find some docs on InitializeComponent() cause I looked at MSDN and couldn't find any. Any advice is greatly appreciated.
Regards
|
|
|
|
|
Of course you can set the properties in the constructor. I bet the VS designer just creates an "InitializeComponents" method so it can better keep track of the changes made directly through the designer.
That's why the designer can get confused if you modify the "InitializeComponents" section too much.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
But is this function automatically called? Because I cannot see any point where it is called.
|
|
|
|
|
Take a closer look at the Form() constructor
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hello Dear...
InitializeComponent() Is not a special thing ! This is a common function. It will call in Constructor.You can move all codes in this function to the constructor directely ! But You can't change this codes in designer ! Designer (VS.NET) Protects this portion of codes.If you change some codes in this area,Designer will reproduce theme at each rebuild.
I hope this was helpful for you,
Bye
|
|
|
|
|
Thanks a lot
|
|
|
|
|
Hi all,
I want to save the sender (object) or the information comming from th controls into an array. How to do that ?
object arr = new object[100];
void xyz_method (object sender, System.EventArgs e)
{
arr[i] = sender; // that didn't work
}
Thank's
regards
Frank
|
|
|
|
|
You have declared arr to be an object rather than an array of objects. That will make arr reference to the array rather than being the array. To use the array you would have to cast arr as being a reference to an array of objects:
((object[])arr)[i] = sender;
Instead, declare arr as an array:
object[] arr = new object[100];
Have you assigned a value to the variable i?
---
b { font-weight: normal; }
|
|
|
|
|
Why didn't that work? That aside, I'd suggest using an ArrayList, as hardcoding the array size as 100 is not a good idea.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi!
Do you know a Documentation or a good book? I want to write an eventhandler which catchs events, if a user writes a new date in the calendar or deletes some dates.
I need an example or something else!
Thanks!
|
|
|
|
|
Hi
I'm trying to execute some code after a dialog is initially displayed (but before the user has control), but I can't find an event that is triggered when this happens. What I'm trying to do is simulate a button click when certain initial conditions exist, but all the events I have tried (such as Activate) don't update the display until after the code has finished executing, and as this takes a relatively long time I need it to show and update my progress bar.
Can anyone help?
TIA
Ian.
|
|
|
|
|
Hi!
The event you're looking for is probably the Load event.
But no matter which event you choose, your GUI will usually not update inside a long-running action unless you call Application.DoEvents() to allow Paint events (and all others) to get a chance to execute.
Regards,
mav
|
|
|
|
|
Hi mav
Thanks for the response - I've tried using the Load event, and I was already using Application.DoEvents() in a couple of places, but even if I put them in the loops I still didn't see any part of the dialog until it had finished processing. However, I've now put in a call to Show() before the processing starts, and this seems to have done the trick!
Regards
Ian.
|
|
|
|
|
Hi, I have a little function for stripping the last part of an url using regular expressions. I did construct the expression in Expresso and have tried it on regexlib.com (http://www.regexlib.com/RETester.aspx). Works beautifully exept in my C# code! Can anyone see what I'm doing wrong.
<br />
private String stripFromUrl( string url )<br />
{<br />
String stripUrlPattern = "(?<fixedUrl>.+(?<=/))";<br />
Regex r = new Regex(stripUrlPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);<br />
string stripurl = r.Replace(url, "${fixedUrl}");<br />
return stripurl;<br />
}<br />
The problem is that the string does not change at all. It just returns the string unchanged!
Please help!
|
|
|
|
|
|
From what I can tell from the documentation, named matches is not supported.
Try using the pattern "(.+(?<=/))" and use the index of the match in the replace: "$1".
---
b { font-weight: normal; }
|
|
|
|
|
I found out what I was doing wrong. I need to match the whole string (not only the part I wanted to extract). So I added a named variable called <rest> to match the rest.
This my current version:
<br />
private String stripFromUrl( string url )<br />
{<br />
String stripUrlPattern = "(?<fixedUrl>http:// [ \\w \\. / ]+) (?(/) (?<rest>.+) | (?<rest>(?<=/).+) )";<br />
Regex r = new Regex(stripUrlPattern, RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);<br />
string stripurl = r.Replace (url, "${fixedUrl}");<br />
return stripurl;<br />
}<br />
|
|
|
|
|
|
I use System.Uri to get the returned url but it returns the filename and parameters also. I'm Changing relative paths to absolute. That's why I need Regex to strip the filename off the Uri.
|
|
|
|
|
Hi,
Here i am facing one problem in making .exe file,whole situation is like below.
My main project is in C#.net and i had made .dll file from that,now client requirement is that,he wants to run the .exe file of our project from vb 6.0 but that must be console application so i had made .dll file from my project and one another .net project include that .dll and then i made .Exe file of that project which is .net console application,it means that my second project is includes .dll of my project and now for testing purpose i had made third project which include second projects only .exe file but now problem is that third project also required first projects .dll otherwise it is not working.
Here is 3 project's outputs and included files.
first project : out of that made .dll file.
second project : made console application and include first project's .dll file and then made .exe file
Third project (for testing) :if i include only second project's .exe then project is not working and if i include second project's .exe and .dll both
if working fine.
Now my question is that why my third project required .dll of second project,actually third project should not required .dll file ,only .exe of second project is enough.
hope you not confused with all of above.
if any query regarding understanding pls ask me.
|
|
|
|
|
Perhaps a little more punctuation would help?
From what I understood, you have 2 executables and a dll. One of the executables is linked to that dll, the other only uses the first executable. If you are asking why the dll is needed, you haven't understood dynamic linking.
DLL (dynamic linked library) means that linking (resolving method names to addressed) takes place when the executable is loaded into memory. Which obviously means that the dll has to be available when the executable is loaded.
Does this make sense?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
I want to cut a mpeg file into parts. I am using MCI from winmm.dll.
I can do play stop, pause , fast forward or slow motion but unable to edit (cut ,copy or paste). could somebody help me? A sample code will help a lot. Thanks in advance.
Ashish
|
|
|
|