N
not_a_commie
Can anyone tell me what's wrong with the following code? It doesn't
compile. The compiler tries to use the wrong overload. Is it a known
bug? Thanks for your time.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace BadOverloads
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
Inherited = false, AllowMultiple = false)]
public abstract class XmlFormatterAttribute : Attribute
{
public abstract string Format(object value);
public abstract object Unformat(string value);
}
public class Program
{
public void func(XmlDocument document, XmlFormatterAttribute
attribute)
{
Console.Out.WriteLine("func1");
}
public void func(XmlDocument document, ref object value)
{
Console.Out.WriteLine("func2:" + value.ToString());
}
static void Main(string[] args)
{
//object testobj = new object();
//func(new XmlDocument(), ref testobj); // this doesn't work either
string str = "howdy";
func(new XmlDocument(), ref str);
}
}
}
compile. The compiler tries to use the wrong overload. Is it a known
bug? Thanks for your time.
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace BadOverloads
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
Inherited = false, AllowMultiple = false)]
public abstract class XmlFormatterAttribute : Attribute
{
public abstract string Format(object value);
public abstract object Unformat(string value);
}
public class Program
{
public void func(XmlDocument document, XmlFormatterAttribute
attribute)
{
Console.Out.WriteLine("func1");
}
public void func(XmlDocument document, ref object value)
{
Console.Out.WriteLine("func2:" + value.ToString());
}
static void Main(string[] args)
{
//object testobj = new object();
//func(new XmlDocument(), ref testobj); // this doesn't work either
string str = "howdy";
func(new XmlDocument(), ref str);
}
}
}