|
//String array
string[] stringArray={"a","b","c"};
//Get a string value at a certain position
string first = stringArray.GetValue(0).ToString();
string second = stringArray.GetValue(1).ToString();
string third = stringArray.GetValue(2).ToString();
//enumerate through the array and get objects
foreach(string s in stringArray)
{
Console.WriteLine(s);
}
Hope this helps.
|
|
|
|
|
string[] myStringArray = new string[]{"foo","bar","due"};<br />
string myStringObject = String.Join(",",myStringArray);<br />
|
|
|
|
|
You can to that in few ways
string[] strArray={"one","two","three"};
// Using foreach
string result = String.Empty;
foreach(string str in strArray)
{
result += str + "\n";
}
//Using ArrayList
StringBuilder sb = new StringBuilder();
foreach(string str in strArray)
{
sb.AppendLine(str);
}
// then for example
Console.Write(sb.ToString());
DEV36 Dominik Goss
|
|
|
|
|
Why would you do either with a perfectly usable String.Join method?
Both your examples are just equivalent to String.Join("\n",strArray)
|
|
|
|
|
Yes, you're right. You code is much more Object-oriented , and shorter
DEV36 Dominik Goss
|
|
|
|
|
hi .
how i can monitor internet traffic ?
(how i can give list of opend websites)
|
|
|
|
|
I don't think you can see what webistes are currently open, you could see what page was last accessed (well, which ip anyway)
But you wouldn't know if a person had closed their browser or anything.
You might be able to somehow get which pages are open from the browser itself, but, i don't know. It doesn't seem likely.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
|
thanks for help.
Judah Himango
|
|
|
|
|
In data Types , i would like to know what is the difference between refrence type and value type ,which is better in using and why ?
thanks ,
Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
The almighty, magical google[^] returned this.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
All hail google.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Actually, there's no point in worrying about this, because you don't really have a choice, most of the time. But, I assume google told you that already.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
It isn't a case of one being better than the other but of the situation you want to use them in.
In the vast majority of cases you'll go with a reference type. Very rarely you might need to create a value type.
Value types are copied each time you pass them around.
Reference types don't get copied, a reference is passed instead.
|
|
|
|
|
Ref Type: (a) is store data in heap memory And Accessing Through Refference.
(b) Efficent And Fast Accessing Method.
(c) Object type,Delegate,Interface,pointer is example that.
value type: (a) is store data in stack memory And Accessing through ordinary variable.
(b) Scope in Single block And another place duplicate complexity.
(c) int,float,double,char etc.
Beshak MOHAMED RASOL ALLAH
ali
|
|
|
|
|
So I am able to successfully enumerate the processes on a machine using the remote machine's name on the network such as:
Process[] myProcesses = Process.GetProcesses("Machine_Name_Here");
However, I'd like to also use myProcesses[0].Kill() for example to kill the process and then after use something like Process.Start("blah") to start it again.
The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Is there anything I can do for this desired functionality?
|
|
|
|
|
InvalidTypecast wrote: The problem I am running into is that Process.Kill is not supported on remote machines. Additionally, I am not sure if I am able to launch the process through Process.Start either.
Neither is starting a remote process, for the obvious security implications.
You can start a NON-INTERACTIVE process remotely using the WMI Win32_Process class. But, again, the user will NOT see any indication that the process is running. It will not be allowed to put up ANY user interface at all.
|
|
|
|
|
Yes, these are just command line applications with no interactivity that I need to restart essentially. Do you know of an article that provides a noobie example on using WMI for this?
|
|
|
|
|
|
Not specifically for the Win32_Process class, but if you Google "C# WMI invoke method", you'll get something like this[^]. You can find the docs on the Win32_Process class here[^]. You're looking for the Create and Terminate methods.
|
|
|
|
|
Hello All,
Greetings!
My task is to retrieve the Date Taken field of images in a folder. Here is the code I have used
//For each file in the folder
void Srch_DT(FileInfo f, string condition,string value)
{
Image img = null;
PropertyItem pi = null;
try
{
img = Image.FromFile(f.DirectoryName + @"\" + f.Name);
pi = img.GetPropertyItem(36867);//Retrieve DateTaken
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
//Something else
}
As I see, if the number of images in the folder is large, I encounter this exception:
" A generic error occurred in GDI+."
What should be done to take care of this error?
Appreciate any help!
Thanks
D
|
|
|
|
|
Hi,
you should call img.Dispose() as soon as you no longer need the image,
so its unmanaged resources don't get lost.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi,
Thanks for that!
However I see the error even I after I use the img.Dispose().
Also it displays Not responding in the title. I am running this on Vista Home Basic.
D
-- modified at 15:01 Monday 22nd October, 2007
|
|
|
|
|
OK,
the problem is GDI+ has only a single error message, the one you are getting;
the next most probable cause is a bad image file, so make sure you see the filename
that is current when the exception occurs (best is to show Exception.ToString, not
just Exception.Message).
Then try if you can open just that one file, my best guess is you won't succeed;
delete (move away) that one file, and try again.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Bingo! Yes there were few corrupted images. It would be ok to by-pass these images.
However one last question..
After the application starts running. it shows Not responding in the title. How could I deal with this? Will this be an performance issue?
Thanks again for the solution!
D
|
|
|
|