{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/2238","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/2238/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/2238/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/2238/events","html_url":"https://github.com/dotnet/roslyn/issues/2238","id":70711317,"number":2238,"title":"What about all the cool features VB can but not C#?","user":{"login":"HugoRoss","id":6603263,"avatar_url":"https://avatars.githubusercontent.com/u/6603263?v=3","gravatar_id":"","url":"https://api.github.com/users/HugoRoss","html_url":"https://github.com/HugoRoss","followers_url":"https://api.github.com/users/HugoRoss/followers","following_url":"https://api.github.com/users/HugoRoss/following{/other_user}","gists_url":"https://api.github.com/users/HugoRoss/gists{/gist_id}","starred_url":"https://api.github.com/users/HugoRoss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HugoRoss/subscriptions","organizations_url":"https://api.github.com/users/HugoRoss/orgs","repos_url":"https://api.github.com/users/HugoRoss/repos","events_url":"https://api.github.com/users/HugoRoss/events{/privacy}","received_events_url":"https://api.github.com/users/HugoRoss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-24T14:59:10Z","updated_at":"2015-04-24T15:45:35Z","closed_at":null,"body":"ISSUE 1:\r\n\r\nIn VB I can easily create an inner interface like this (or also an inner class within an interface): \r\n\r\nPublic Interface ICustomerService\r\n\r\n    Function Save(customer As ICustomer) As IMethodResult\r\n\r\n    Interface Version2\r\n        Inherits ICustomerService\r\n\r\n        Sub SaveAsync(customer As ICustomer, callback As Action(Of IMethodResult))\r\n\r\n    End Interface\r\n\r\n    Interface Version3\r\n        Inherits ICustomerService.Version2\r\n\r\n        Overloads Function SaveAsync(customer As ICustomer) As Guid\r\n        Function GetMethodResult(trackingNumber As Guid) As IMethodResult\r\n\r\n    End Interface\r\n\r\nEnd Interface\r\n\r\nWhen can I do this in C#?\r\n----------------\r\nISSUE 2:\r\n\r\nC# compiler is poor in field initializations like this, which the VB compiler handles without any problem:\r\n\r\n    public class OuterClass {\r\n\r\n        private InnerClass _InnerClass = new InnerClass(this); // <-COMPILE ERROR!\r\n\r\n        private class InnerClass {\r\n\r\n            private OuterClass _OuterInstance;\r\n\r\n            public InnerClass(OuterClass outerInstance) {\r\n                _OuterInstance = outerInstance;\r\n            }\r\n\r\n        }\r\n\r\n    }\r\n\r\nSame problem which field initialization of fields that reference a previously initialized field. In VB, no problem, in C# a compile error occurs:\r\n\r\n    public class Test {\r\n\r\n        private Int32 _FieldA = 55;\r\n        private Int32 _FieldB = _FieldA * 5; // <-COMPILE ERROR!\r\n        private List<String> _Cache = new List<String>(_FieldA + _FieldB); // <-COMPILE ERROR!\r\n\r\n    }\r\n\r\n\r\nISSUE 3:\r\nC# compiler is poor in compiling foreach loops, which the VB compiler handles without any problem:\r\n\r\n        public void DoSomething(IEnumerable<String> stringCollection) {\r\n            foreach (String myString in stringCollection) {\r\n                myString = myString ?? \"\"; // <- COMPILE ERROR!\r\n                //Do something with it\r\n            }\r\n        }\r\n\r\nWhen are these issues fixed?\r\n\r\nThank you\r\nChris"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/95971759","html_url":"https://github.com/dotnet/roslyn/issues/2238#issuecomment-95971759","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/2238","id":95971759,"user":{"login":"HaloFour","id":10102290,"avatar_url":"https://avatars.githubusercontent.com/u/10102290?v=3","gravatar_id":"","url":"https://api.github.com/users/HaloFour","html_url":"https://github.com/HaloFour","followers_url":"https://api.github.com/users/HaloFour/followers","following_url":"https://api.github.com/users/HaloFour/following{/other_user}","gists_url":"https://api.github.com/users/HaloFour/gists{/gist_id}","starred_url":"https://api.github.com/users/HaloFour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HaloFour/subscriptions","organizations_url":"https://api.github.com/users/HaloFour/orgs","repos_url":"https://api.github.com/users/HaloFour/repos","events_url":"https://api.github.com/users/HaloFour/events{/privacy}","received_events_url":"https://api.github.com/users/HaloFour/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T15:45:35Z","updated_at":"2015-04-24T15:45:35Z","body":"None of these are problems, just differences between the languages.  The languages aren't supposed to be the same.\r\n\r\nIssue 1:\r\n\r\nThis is an inherent difference in how the two languages handle field initializers.  The C# compiler initializes fields before calling the base constructor.  The VB.NET compiler initializes fields after.  As such the C# compiler cannot assign or use `this` in a field initializer because `this` does not exist yet.  At the same time, the VB.NET compiler is incapable of having fields initialized before the base constructor is called.  Neither are wrong, just different.\r\n\r\nIssue 2:\r\n\r\nThe C# compiler explicitly decided that nested interfaces shouldn't be permitted.  This is a design choice.\r\n\r\nIssue 3:\r\n\r\nIt doesn't make a lot of sense for the iterator variable to be modified.  I'd side with C# here in terms of correct behavior.  If you want to have a modified value, assign it to a temporary variable."}}