2017-04-04 6 views
9

विजुअल स्टूडियो 2017 में, "त्वरित कार्रवाइयां और refactorings" मेनू, जब मैं क्लिक करें "इंटरफ़ेस लागू", मैं कार्यान्वयन कि सी # के नए लक्षणों का उपयोग मिलता है, इस तरह में:क्या विजुअल स्टूडियो 2017 का "कार्यान्वयन इंटरफेस" कमांड सी # 5 कोड उत्पन्न कर सकता है?

public int ConnectionTimeout => throw new NotImplementedException(); 

समस्या यह है कि मेरी कंपनी सी # 5 का उपयोग कर रही है और इसलिए हम इस नए वाक्यविन्यास का उपयोग नहीं कर सकते हैं। मैं जानता हूँ कि दृश्य स्टूडियो के पुराने संस्करणों के लिए इस कोड के बजाय उत्पन्न होगा:

public int ConnectionTimeout { get { throw new NotImplementedException(); } } 

वहाँ एक रास्ता दृश्य स्टूडियो 2017 यह करने के लिए प्राप्त करने के लिए है? मैंने अपनी परियोजना को सी # 5.

संपादित करके संकलित करने के लिए सेट किया है: मैंने देखा है कि कोड जेनरेटर असंगत है। यदि इंटरफ़ेस में एक बूल सदस्य होता है जिसमें केवल गेटटर होता है, तो यह पुराने वाक्यविन्यास का उपयोग करता है। अन्यथा यह नए वाक्यविन्यास का उपयोग करता है। इससे मुझे लगता है कि मैं भाग्य से बाहर हूं।

private interface myint 
{ 
    bool bool1 { get; } 
    bool bool2 { get; set; } 
    bool bool3 { set; } 

    int int1 { get; } 
    int int2 { get; set; } 
    int int3 { set; } 

    string string1 { get; } 
    string string2 { get; set; } 
    string string3 { set; } 
} 

private class myclass : myint //I clicked "Implement Interface" on this 
{ 
    public bool bool1 
    { 
     get 
     { 
      throw new NotImplementedException(); 
     } 
    } 

    public bool bool2 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } 
    public bool bool3 { set => throw new NotImplementedException(); } 

    public int int1 => throw new NotImplementedException(); 

    public int int2 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } 
    public int int3 { set => throw new NotImplementedException(); } 

    public string string1 => throw new NotImplementedException(); 

    public string string2 { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } 
    public string string3 { set => throw new NotImplementedException(); } 
} 
+0

, उन्नत टैब के अंतर्गत, 5 autogened कोड बदल बदल रहा डिफ़ॉल्ट भाषा C# करता है? – Kyle

+1

@ केली, नहीं, ऐसा नहीं है। मैं इसे अपने प्रश्न में जोड़ना भूल गया – user2023861

उत्तर

8

जाओ लिए उपकरण -> विकल्प -> पाठ संपादक -> संहिता शैली -> सामान्य, कोड ब्लॉक प्राथमिकताओं के अनुभाग स्क्रॉल करें और वरीयता बदलने गुण के लिए, indexers और के लिएसे "अभिव्यक्ति ब्लॉक पसंद करें" (डिफ़ॉल्ट) "ब्लॉक बॉडी पसंद करें"

enter image description here

परियोजना संपत्तियों पर
संबंधित मुद्दे