However, params can work like you mentioned.  It was a misunderstanding of
params on my part.

Originally, I thought params could only be used for variable arguments.
However, it can also be used to pass the values as an array too.

Here is a test program that demonstrates this:

using System;

public class ParamsTest {
        public ParamsTest (params int[] args)
        {
                Console.WriteLine("\tParamsTest");
                for (int a = 0; a < args.Length; a++) {
                        int arg = args[a];
                        string result = "\t\tArgs[" + a.ToString() + "] = " + 
args[a].ToString();
                        Console.WriteLine (result);
                }
        }
}

public class TestParamsDriver
{
        public static void Main(string[] args)
        {
                Console.WriteLine("Variable args");
                ParamsTest pt1 = new ParamsTest (1);
                ParamsTest pt2 = new ParamsTest (2,3);
                ParamsTest pt3 = new ParamsTest (4,5,6);
                ParamsTest pt4 = new ParamsTest (7,8,9,10);

                Console.WriteLine("Array of args");
                int numberOfArgs = 5;
                int start = 11;

                int[] theArgs = new int[numberOfArgs];

                for (int p = 0;  p < numberOfArgs; p++) {
                        theArgs[p] = start + p;
                }
                ParamsTest pt5 = new ParamsTest (theArgs);
                Console.WriteLine("Done.");
        }
}

This is what it displays:

DanielMorgan@DANPC ~
$ mcs TestParams.cs
Compilation succeeded

DanielMorgan@DANPC ~
$ mono TestParams.exe
Variable args
        ParamsTest
                Args[0] = 1
        ParamsTest
                Args[0] = 2
                Args[1] = 3
        ParamsTest
                Args[0] = 4
                Args[1] = 5
                Args[2] = 6
        ParamsTest
                Args[0] = 7
                Args[1] = 8
                Args[2] = 9
                Args[3] = 10
Array of args
        ParamsTest
                Args[0] = 11
                Args[1] = 12
                Args[2] = 13
                Args[3] = 14
                Args[4] = 15
Done.

Moreover, we could make the SetColumnTypes to use a params as well:

This would be the desired generated output:

static extern void gtk_list_store_set_column_types (IntPtr raw, int
n_columns, int[] types);

public void SetColumnTypes(params int[] types)
{
        gtk_list_store_set_column_types (Handle, types.Length, types);
}

Here is what I have for Gtk.metadata:

<rule>
  <class name="GtkListStore">
    <method>SetColumnTypes</method>
  </class>
  <data>
    <attribute target="param">
      <filter level="name">types</filter>
      <name>pass_as</name>
      <value>length_param</value>
  </data>
</rule>

I have no idea how to test it.  Is the above okay?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Kristian Rietveld
Sent: Thursday, November 21, 2002 1:19 PM
To: Daniel Morgan
Cc: Mike Kestner; Mono-List
Subject: RE: [Mono-list] GTK# Patch for TreeStore, ListStore, and
TextIter


On Thu, 2002-11-21 at 04:12, Daniel Morgan wrote:
> SetColumnTypes should be an array like the GTK+ 2.0 API says:

Oh blah I see now. Dunno why I was comparing this function with the
constructors .... I guess I was already sleeping...


apologies,


        Kris


_______________________________________________
Mono-list maillist  -  [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to