Skip to main content
 首页 » 编程设计

c#之C# 类库中对象的类、方法、变量大小写/名称的最佳实践是什么

2024年02月05日9langtianya

<分区>

我是一些小众语言的强大开发人员,并且正在有机地学习 C#,因此尝试学习最佳实践。

我能否获得一些关于以下示例代码块的最佳反馈,例如,我正在构建 Shopify 集成。

namespace WMShopify 
{ 
    // Is it common to have the namespace and class the same? 
    public class WMShopify 
    { 
        // Are there different practices for private/public vars? 
        public string APIKey { get; set; } // Capital 
        public string password { get; set; } // lower case 
        public string secretString { get; set; } // Camel 
        private string _combinedVar; // Camel/underscore for private 
    } 
 
    // Should these be in a separate *.cs file? 
    public class WMShopifyOrders 
    { 
        // Method capital/lower/camel? 
        public int getOrderCount() 
        { 
            // lower/capital/camel? 
            int localMemberVar = 0; 
 
            return localMemberVar; 
        } 
    } 
 
    // Should these be in a separate *.cs file? 
    public class WMShopifyProducts 
    { 
        public List<string> getProductList() 
        { 
            return new List<string>(); 
        } 
    } 
}