M
Marco Segurini
Hi,
Building the following code
namespace DelegateAnonymousToMap
{
class Program
{
class MyClass { }
static void Main(string[] args)
{
System.Collections.Hashtable hash = new
System.Collections.Hashtable();
hash.Add(1, delegate() { return new MyClass(); });
}
}
}
I get:
C:\..\Program.cs(14,10): error CS1502: The best overloaded method match
for 'System.Collections.Hashtable.Add(object, object)' has some invalid
arguments
C:\..\Program.cs(14,22): error CS1503: Argument '2': cannot convert from
'anonymous method' to 'object'
How may I solve this problem using anonymous delegate?
TIA.
Marco.
Building the following code
namespace DelegateAnonymousToMap
{
class Program
{
class MyClass { }
static void Main(string[] args)
{
System.Collections.Hashtable hash = new
System.Collections.Hashtable();
hash.Add(1, delegate() { return new MyClass(); });
}
}
}
I get:
C:\..\Program.cs(14,10): error CS1502: The best overloaded method match
for 'System.Collections.Hashtable.Add(object, object)' has some invalid
arguments
C:\..\Program.cs(14,22): error CS1503: Argument '2': cannot convert from
'anonymous method' to 'object'
How may I solve this problem using anonymous delegate?
TIA.
Marco.