Why is GUID attribute needed in the first place?(为什么首先需要 GUID 属性?)
问题描述
GUID 属性的必要性是什么?为什么不让编译器自动处理呢?!
What is the necessity for the GUID attribute? why don't just let the compiler handle this automatically?!
推荐答案
如果编译器自动处理这个问题,你最终会遇到两种情况之一.
If the compiler handled this automatically, you'd end up with one of two situations.
每次编译时都会创建一个新的 GUID - 因为应该发布 GUID,所以这会失败.
A new GUID every time you compiled - since GUIDs are supposed to be published, this would fail.
冲突 - 如果 GUID 每次都相同,则基于(例如)名称的哈希,多个项目最终会出于不同目的使用相同的 GUID.
Collisions - if the GUID was the same every time, based on (say) a Hash of the name, multiple projects would end up using the same GUID for different purposes.
现有方法 - 显式 GUID 使开发人员能够根据需要控制这些.
The existing approach - an explicit GUID gives developers the power to control these as required.
这篇关于为什么首先需要 GUID 属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么首先需要 GUID 属性?
基础教程推荐
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- WPF 模态进度窗口 2022-01-01
