Click here to Skip to main content
16,006,749 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to call the buttons dynamically for my own form in c# Pin
Stefan Troschuetz16-Dec-06 1:06
Stefan Troschuetz16-Dec-06 1:06 
QuestionChild Node Text ????????????? Pin
sajid.salim.khan15-Dec-06 20:36
sajid.salim.khan15-Dec-06 20:36 
AnswerRe: Child Node Text ????????????? Pin
Stefan Troschuetz15-Dec-06 21:11
Stefan Troschuetz15-Dec-06 21:11 
QuestionAccess Active Document In Word Template Project Pin
AmitSumit15-Dec-06 20:28
AmitSumit15-Dec-06 20:28 
Questioncode of remember me!!! Pin
Ashish Porwal15-Dec-06 20:12
Ashish Porwal15-Dec-06 20:12 
AnswerRe: code of remember me!!! Pin
toxcct22-Jan-07 10:28
toxcct22-Jan-07 10:28 
QuestionTriggers on sqlserver Pin
vikram92915-Dec-06 19:24
vikram92915-Dec-06 19:24 
QuestionPassing a collection object to a method as a ref parameter... or not? Pin
lvanerstrom15-Dec-06 17:44
lvanerstrom15-Dec-06 17:44 
Hello:

I'm having a bit of trouble understanding the use of passing a collection object (in my case an ArrayList) as a ref parameter to a method that needs to add to the collection or otherwise modify the ArrayList's contents. Basically, I'm wondering which is the better, or more accepted, way to do this.

Consider the following bit of code - Both of my Test methods will modify the contents of my ArrayList and allow me to access all the values in my Main() method. However, I don't really understand which would be the better way to do it. Could someone please provide me a bit of understanding on this particular use of ref? Maybe what the pros and cons are of the two ways I do it here... why would I pick one way over the other?

Thanks!

using System;
using System.Collections;

namespace TestConsoleApplication
{
internal class TCA
{
[STAThread]
private static void Main(string[] args)
{
try
{
ArrayList List = new ArrayList();
List.Add(1);
List.Add(2);

Console.WriteLine("Passing the array:");
Test(List);
foreach (int i in List)
{
Console.WriteLine(i);
}

Console.WriteLine("\nPassing the array as a ref parameter:");
Test(ref List);
foreach (int i in List)
{
Console.WriteLine(i);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}

#region Pause

Console.WriteLine();
Console.WriteLine("Done.");
Console.ReadLine();

#endregion
}

private static void Test(ArrayList list)
{
list.Add(3);
list.Add(4);
}

private static void Test(ref ArrayList list)
{
list.Add(5);
list.Add(6);
}
}
}
AnswerRe: Passing a collection object to a method as a ref parameter... or not? Pin
Guffa15-Dec-06 18:27
Guffa15-Dec-06 18:27 
GeneralRe: Passing a collection object to a method as a ref parameter... or not? Pin
lvanerstrom15-Dec-06 18:34
lvanerstrom15-Dec-06 18:34 
QuestionAnybody know how to upload video using ASP.NET? Pin
mujin0315-Dec-06 17:12
mujin0315-Dec-06 17:12 
AnswerRe: Anybody know how to upload video using ASP.NET? Pin
Alper Camel17-Dec-06 9:04
Alper Camel17-Dec-06 9:04 
QuestionGetting dynamic Datagrid Pin
narendrakumarp15-Dec-06 16:39
narendrakumarp15-Dec-06 16:39 
QuestionNewbie problems Pin
new to this15-Dec-06 15:10
new to this15-Dec-06 15:10 
AnswerRe: Newbie problems Pin
Guffa15-Dec-06 17:08
Guffa15-Dec-06 17:08 
QuestionCreating an own Rectangle class Pin
babbelfisken15-Dec-06 13:30
babbelfisken15-Dec-06 13:30 
AnswerRe: Creating an own Rectangle class Pin
Guffa15-Dec-06 15:58
Guffa15-Dec-06 15:58 
AnswerRe: Creating an own Rectangle class Pin
CPallini15-Dec-06 22:29
mveCPallini15-Dec-06 22:29 
Questionpersistant variable? Pin
amatbrewer15-Dec-06 13:12
amatbrewer15-Dec-06 13:12 
AnswerRe: persistant variable? Pin
Guffa15-Dec-06 17:20
Guffa15-Dec-06 17:20 
JokeRe: persistant variable? Pin
amatbrewer18-Dec-06 5:24
amatbrewer18-Dec-06 5:24 
AnswerRe: persistant variable? Pin
Luc Pattyn15-Dec-06 18:47
sitebuilderLuc Pattyn15-Dec-06 18:47 
GeneralRe: persistant variable? Pin
Guffa15-Dec-06 19:20
Guffa15-Dec-06 19:20 
GeneralRe: persistant variable? Pin
Luc Pattyn16-Dec-06 4:35
sitebuilderLuc Pattyn16-Dec-06 4:35 
GeneralRe: persistant variable? Pin
Guffa16-Dec-06 16:04
Guffa16-Dec-06 16:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.