5

I'm currently using Visual Studio (specifically, 2012 Express). I have an interface already defined as follows:

interface IMyInterface
{
    public String Data { get; set; }
}

If I have an empty class:

class MyClass : IMyInterface
{
}

And I right-click on the IMyInterface, I can select "Implement Interface". When I do this, the auto-generated code produces the following:

class MyClass : IMyInterface
{
    public string Data
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }
}

My question is, is there a way that I could have the following auto-generated:

    public String Data

Instead of:

    public string Data

?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
jdknight
  • 1,801
  • 32
  • 52
  • I wish, but I haven't found an option. – Fls'Zen Apr 21 '13 at 02:23
  • 2
    Not sure why this is important. String and string are same; second one is alias of the first. As far as I know, VS will always fall back into alias for native types, e.g. Int32 as int; Int64 as long etc. – loopedcode Apr 21 '13 at 02:26
  • 1
    You may want to read this: http://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string – Bit Apr 21 '13 at 02:27
  • No there isn't a way. Also, you should not (meaning you can, but it's better not to for readability reasons) use the class name and instead use the alias. Just like you do "int i" instead of Int32 i. If you want to call a static function then it makes sense to use the class name. Like Int32.TryParse(). – santahopar Apr 21 '13 at 04:53
  • Use `string` in your interface and your problem will disappear:) – huysentruitw Apr 21 '13 at 05:18
  • You could create your own T4 template, but this seems like overkill in this specific case. – Elad Lachmi Apr 21 '13 at 07:22

1 Answers1

1

There is no way to do this. It's hard-coded to use the builtin aliases where possible.

Jay Bazuzi
  • 45,157
  • 15
  • 111
  • 168