|
ok
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
See the code snippet copied from MSDN. Hope this helps...
using System;<br />
public class MyClass <br />
{<br />
<br />
public static void UseParams(params int[] list) <br />
{<br />
for (int i = 0 ; i < list.Length; i++)<br />
{<br />
Console.WriteLine(list[i]);<br />
}<br />
Console.WriteLine();<br />
}<br />
<br />
public static void UseParams2(params object[] list) <br />
{<br />
for (int i = 0 ; i < list.Length; i++)<br />
{<br />
Console.WriteLine(list[i]);<br />
}<br />
Console.WriteLine();<br />
}<br />
<br />
static void Main() <br />
{<br />
UseParams(1, 2, 3);<br />
UseParams2(1, 'a', "test"); <br />
<br />
int[] myarray = new int[3] {10,11,12};<br />
UseParams(myarray);<br />
}<br />
}
|
|
|
|
|
One way to do this, is to use the params keyword. The only problem is that you have no control over what the developer puts in, but this is how things like string.Format work. Example:
public void DoSomething(params string[] items)
{
if (items != null && items.Length > 0)
{
foreach (string item in item)
{
}
}
}
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How can we cast a string to stream?
I want to load a string in XmlDocument.load(string)
-- modified at 1:56 Tuesday 7th August, 2007
Pavas
|
|
|
|
|
if your string contains a xml file you can simply load it into the xmDocument using LoadXml Method however if you need the stream it's can not be Casted you must write your string to a Stream by your self here it is too
<br />
string str;
<br />
XmlDocument xmlDoc=new XmlDocument();<br />
xmlDoc.LoadXml(str);<br />
<br />
<br />
MemoryStream stream = new MemoryStream();<br />
<br />
StreamWriter sw = new StreamWriter(stream);<br />
sw.Write(str);<br />
<br />
good luck
|
|
|
|
|
can i send the control to somewhere , like in vb goto statement.
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
C# supports goto. People just don't use it, because it's been well established for a long time, that it's generally a bad idea to do so. Someone will inevitably respond with 'I use goto wisely, it's just a tool'. Perhaps. All I know is, I understand how it can tend towards bad code, and I never have any use for it.
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 )
|
|
|
|
|
ok thanks
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Isn't goto supported in switch statements only?
switch (something)
{
case A:
goto B;
case B:
break;
}
Sometimes this is very useful.
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
Hi,
I have some struct that one of the fields of it is some ArrayList.
I also have some function in my project that one of the parameters that need to get is ArrayList.
Now ... in starting of my program - the ArrayList is null and in this function i do "new ArrayList" in case this ArrayList is null.
But (!!!) when i getting into this function i see that the allocate of the new ArrayList is OK and i adding new object into this ArrayList - but in out of this function i see that this ArrayList is null (!!!) of course and all the object that i add to it are missing.
How can it be ? as far as i know the parameters in this case are always delivered by reference.
What to do to solve this problem ?
Thanks for any help.
|
|
|
|
|
the argumnent name you receive int your method is just like another pointer to your reference so when you associate a new object to it you will lose the old reference object
for doing this you must use out or ref before it (simply out).
<br />
<br />
ArrayList arr = null;<br />
NewArr(out arr);<br />
}<br />
<br />
static void NewArr(out ArrayList arr)<br />
{<br />
arr = new ArrayList();<br />
}<br />
Good Luck
|
|
|
|
|
Yanshof wrote: as far as i know the parameters in this case are always delivered by reference
No, by default parameters are passed by value, as in C;
you can force them to be passed by reference by adding a "ref" or "out" keyword
(or an ampersand in C)
if you pass a value type, nothing more is to be said.
if you pass a reference type, the "value" is the reference, so the callee can use it,
change what it is refering to, but can not change the reference itself as seen by the
caller; if passing a reference type with "ref"/"out" keyword, then the callee can change
the reference itself as seen by the caller.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/AllLanguages/General
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi there,
Here i am stucked with a problem regarding windows application
can any one plz help me on finding that, is it possible to detect a default palyer set on the local system.
I want to detect the default player set on teh local system where application is running.
Thanks in advance
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
sulabh2020 wrote: default palyer
I assume you meant "player", which begs the question: player of what?
/ravi
|
|
|
|
|
I am talking about anyu media player(like winamp, juke box etc..) including Windows medis player.
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
can i increase the array a runtime,like in vb,redim keyword do, is it possible in c#,
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
|
sir in 2.0?
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
Sonia Gupta wrote: sir in 2.0?
You just do yourself what the Resize method does; create a new array and copy the values to it.
---
single minded; short sighted; long gone;
|
|
|
|
|
ok thanks
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
It's actually in .NET 2 and beyond, so it's available now.
David Anton
http://www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
C++ to VB Converter: converts C++ to VB
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
You can't resize an array in .NET.
Create a new array and copy the items to it.
(That's what the ReDim command does in VB.NET.)
---
single minded; short sighted; long gone;
|
|
|
|
|
ok thanks
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
hi i want to read the pen drive autorun file and want to add my own file there at startup.
Secondly from where can i get information about what happens when any drive is double-clicked.
thanx in advance
|
|
|
|
|
Hey ya'll
Has anyone ran across this error in VS2005? WTF?
"The designer loader did not provide a root component but has not indicated why."
As a general rule doesn't display this message the designer just doesn't display anything so I have to reload it after every change?
Thanks,
Mike
Life is not measured by the number of breaths we take, but by the
moments that take our breath away. "George Carlin"
|
|
|
|