首页 \ 问答 \ 冗余类型转换(Redundant type conversion)

冗余类型转换(Redundant type conversion)

在一个代码示例中:

int age;
...
age = (int)Convert.ToInt32(Console.ReadLine());

我认为在转换之前放置(int)没有意义。 我可以安全地删除它:

age = Convert.ToInt32(Console.ReadLine());

有相同的情况,例如:

height = (double)Convert.ToDouble(Console.ReadLine());

In a code example:

int age;
...
age = (int)Convert.ToInt32(Console.ReadLine());

I see no point to put (int) before conversion. Can I safely remove it to:

age = Convert.ToInt32(Console.ReadLine());

There are the same cases, such as:

height = (double)Convert.ToDouble(Console.ReadLine());

原文:https://stackoverflow.com/questions/30010759
更新时间:2022-03-29 19:03

最满意答案

密钥保险库不支持秘密分层结构。

为了模拟结构,您可以做类似于.NET Core与其密钥库配置提供程序的功能。 您可以指定一个名称为Settings--SomeCategory--SomeValue的秘密,并且在加载时它将对应于以下JSON:

{
  "Settings": {
    "SomeCategory": {
      "SomeValue": "value goes here"
    }
  }
}

所以基本上,您可以使用分隔符来模拟结构,这与Azure Blob存储模拟文件夹的方式类似。


Key Vault does not support hierarchies for secrets.

To emulate structure, you can do something similar what .NET Core does with its Key Vault configuration provider. You can specify a secret with a name like Settings--SomeCategory--SomeValue, and it'll correspond to the following JSON when loaded:

{
  "Settings": {
    "SomeCategory": {
      "SomeValue": "value goes here"
    }
  }
}

So essentially you can use a separator to emulate the structure, similar also to how Azure Blob Storage emulates folders.

相关问答

更多
  • 使用闭包表。 如果基本结构是具有字段ID和ParentID的父子结构,则闭包表的结构是ID和DescendantID。 换句话说,闭包表是祖先 - 后代表,其中每个可能的祖先与所有后代相关联。 如果需要,您可以包含LevelsBetween字段。 闭包表实现通常包括自引用记录,即ID 1是子级ID 1的祖先,LevelsBetween为零。 示例:父/子 ParentID - ID 1 - 2 1 - 3 3 - 4 3 - 5 4 - 6 祖先/后代 ID - DescendantID - LevelsB ...
  • 由于oms位于其他资源组中,因此您需要为其提供资源组。 "workspaceId":"[resourceId('myresourcegroup', 'Microsoft.OperationalInsights/workspaces', parameters('omsWorkspaceName'))]", since the oms is in the other resource group, you need to provide it the resource group. "workspaceId" ...
  • 我重新组织了我的数据结构,分别存储'data'字段,使树结构足够小,完全适合客户端。 对于树中的每个节点,我使用通向节点的路径作为存储“数据”的键。 例如, root: 2: 0: 3: size: 123 data: [ //list of items ] 存储为: root: 2: 0: 3: size: 123 ...
  • 您可以通过使用@JoinColumn注释而不是我怀疑您正在使用的@JoinTable注释来避免3个额外的映射表。 所以对于例如, 国家 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy="country") private List stateList; 州 @ManyToOne @JoinColumn(name="country_id") private Country country 数据库表 ...
  • 密钥保险库不支持秘密分层结构。 为了模拟结构,您可以做类似于.NET Core与其密钥库配置提供程序的功能。 您可以指定一个名称为Settings--SomeCategory--SomeValue的秘密,并且在加载时它将对应于以下JSON: { "Settings": { "SomeCategory": { "SomeValue": "value goes here" } } } 所以基本上,您可以使用分隔符来模拟结构,这与Azure Blob存储模拟文件夹的方式类似。 ...
  • 有多种选择来更新现有的keyvault访问策略。 在C#中,我们可以使用keyvault nuget包和Keyvaultmanagementclient类来管理azure keyvault。 我们还可以使用Powershell commandlet S et-AzureRmKeyVaultAccessPolicy更新keyvault访问策略。 当然,使用Azure RM rest API也可以实现同样的效果。 保管库 - 更新访问策略 。 There are multiple options to upda ...
  • 请参阅此链接 。 objectId string是Vault的Azure Active Directory租户中的用户,服务主体或安全组的对象ID。 对象ID对于访问策略列表必须是唯一的。 您可以在Enterprise applications - All applications上找到对象ID Enterprise applications - All applications都不是App registrations 。 您还可以使用Power Shell获取对象ID。 Get-AzureADServic ...
  • 我不确定除了问题中提到的那些问题之外,还需要做什么类型的查询,但是将数据存储在明确的祖先层次结构中会让您询问的数据非常容易出错。 例如,要获得来自特定产地的所有葡萄酒: origin_key = db.Key.from_path('Origin', 123) wines_query = db.Query(Wine).ancestor(origin_key) 或从特定的酒庄获得所有葡萄酒: origin_key = db.Key.from_path('Origin', 123) winery_key = d ...
  • 检查我对类似帖子的回答。 解决方案使用递归CTE。 此解决方案还涉及id列和其他排序键列,您可以将其添加到源表(或查询)以进行自定义排序。 Check my answer to a similar post. Solution used a recursive CTE. This solution also involved an id column, and an additional sort key column, which you could add to your source table (o ...
  • 我知道在你班上有公共领域被认为是个坏主意。 这是来自上一个十年Java开发的全面声明。 您应该考虑成员在成员基础上是公共还是私有。 有时公共数据成员是正确的想法。 请考虑以下问题: 我是否需要对此会员保持不变? 该会员可以拥有无效价值吗? 我是否希望界面为该成员提供替代表示? 如果上述任何问题的答案都是肯定的,那么您可能想要使用一个getter。 还要考虑单独设置成员是否真的有意义。 也许您应该使用构造函数设置成员,并且您希望提供一些修改这些成员的其他接口。 在C ++中使用setter和getter时,像 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)