我想界定一种尼布尔型。
我想,如果用户设定的价值高于0xf
,那么该数值就会产生汇编错误。
这是可能的吗?
我想界定一种尼布尔型。
我想,如果用户设定的价值高于0xf
,那么该数值就会产生汇编错误。
这是可能的吗?
无,C#汇编者不可能这样做。
它没有事先加工商可以测试C/C++加工商等固定价值。
你可以做的是,在时间上放弃一个例外。
Edit:你总是可以通过C/C++预处理器操作C#代码(稍作改动),并发布<代码>#err指令。
<><>Edit>:
参看语言学,是的,在支持某种宏观扩张或汇编时间评价的任何大地里,你很容易做到。 例如:计划、LISP、C/C++等。
如在您的网页上USER
,则DEVELOPER
。 你们可以这样作:
#if YOUT_VALUE == 0xf
#error YOUR_ERROR_MESSAGE
#endif
但是,在某些发展动态中,你可能会在<代码>#if说明中的比较方面遇到问题,因为其功能被削减为不忠/只界定。
您可使用埃南语和[Flags]属性。 顺便提一下:
[Flags]
enum Nibble
{
_0,
_1,
// ...
_A,
_F,
};
byte b = Nibble._1|Nibble._A;
你们还可以制造一种可笑的碎石,即暗中转换操作者从 in到灭.。 但这会造成时间错误,而不是汇编时间错误。
如果你想进行静态检查,请看第4号合同。
它像实现你想要的东西的最容易的方法一样,是一种奇怪的类型。 辅助语言在Algol68继承线(Algol68, Pascal, Modula-2, Oberon, Part Pascal)及其表象和衍生工具(Turbo Pascal, Borland Pascal, FreePascal, Delphi, Kylix, Object Pascal)以及Ada。 我认为,你可以在C++中使用一些重模版。 也许,你能够以各种语言实施这些系统,如Schala、Haskell、ML、Ada、Peogram、Guru。
我不知道为什么不会有更多的语言支持次距离类型。 它们显然有用、易于使用、容易理解、易于执行。
另一种可能性可能受到重视。 在福特堡,各种固定的主食类型实际上并未纳入语言,而是对用户加以界定。 因此,没有理由不能够建立your /em>用户确定的固定-width integer型。
As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
I have two EF entities. One has a property called HouseNumber. The other has two properties, one called StartHouseNumber and one called EndHouseNumber. I want to create a many to many association ...
I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....
I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...
I ve got some code which sets up a datacontext. Often enough, the datacontext should be set to some underlying data collection, such as an ObservableCollection - but occasionally I d like to set it ...
I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...
NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...