clr

Why value-types are stored onto Stacks?

空扰寡人 提交于 2019-11-26 10:54:43
问题 Why does C# (.Net) prefer stack to store value types? What is the primary reason behind this design? Is it because read/write operations to the stack take better advantage of the machine processor? Also, maybe you can justify why not others? 回答1: Eric Lippert discusses this here; firstly, it is incorrect that "value types are stored on the stack". They sometimes are, but not as: fields on a class captured variables variables in an iterator block When they can be stored on the stack it is a

Why does Random.Next() always return the same number [duplicate]

回眸只為那壹抹淺笑 提交于 2019-11-26 09:45:28
问题 This question already has answers here : Random number generator only generating one random number (9 answers) Closed 4 years ago . Consider this method: private static int GenerateRandomNumber(int seed, int max) { return new Random(seed).Next(max); } On my machine, executing this loop yields the same number through 1500 iterations: for (int i = 0; i < 1501; i++) { int random = GenerateRandomNumber(100000000, 999999999); Console.WriteLine(random.ToString()); Console.ReadKey(); } I get

Float vs Double Performance

≡放荡痞女 提交于 2019-11-26 09:18:37
问题 I did some timing tests and also read some articles like this one (last comment), and it looks like in Release build, float and double values take the same amount of processing time. How is this possible? When float is less precise and smaller compared to double values, how can the CLR get doubles into the same processing time? 回答1: On x86 processors, at least, float and double will each be converted to a 10-byte real by the FPU for processing. The FPU doesn't have separate processing units

Hosting CLR in Delphi with/without JCL - example

谁说我不能喝 提交于 2019-11-26 08:59:16
问题 Can somebody please post here an example how to host CLR in Delphi? I have read similar question here but I cannot use JCL as I want to host it in Delphi 5. Thank you. EDIT: This article about hosting CLR in Fox Pro looks promising but I don\'t know how to access clrhost.dll from Delphi. Edit 2: I give up on Delphi 5 requirement. Now I\'m trying JCL with Delphi 7. But again I am unable to find any example. Here is what I have till now: My C# assembly: namespace DelphiNET { public class

How do the .NET Framework, CLR and Visual Studio version numbers relate to each other?

自闭症网瘾萝莉.ら 提交于 2019-11-26 08:58:31
问题 With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio. Is there a definitive table that shows these relationships? 回答1: Visual Studio CLR .NET Framework ---------------------------------------------------------------------------------------- Visual Studio .NET (Ranier) 1.0.3705 1.0 Visual Studio 2003 (Everett) 1.1.4322 1

How to detect which .NET runtime is being used (MS vs. Mono)?

那年仲夏 提交于 2019-11-26 08:20:07
问题 I would like to know during execution of a program whether it is being executed using the Mono runtime or the Microsoft runtime. I\'m currently using the following code to determine whether I\'m on a MS CLR: static bool IsMicrosoftCLR() { return RuntimeEnvironment.GetRuntimeDirectory().Contains(\"Microsoft\"); } However, this is somewhat dependent on the installation folder of the runtime and I\'m not sure whether this will work on all installations. Is there a better way to check for the

Resolve assembly references from another folder

让人想犯罪 __ 提交于 2019-11-26 07:42:37
问题 I am developing an application which references and uses some third party assemblies from a certain Vendor; in development box I have these 3 assemblies in a reference folder in my source tree and I can reference them and build the application, application builds but does not run because the whole server application is not installed, but this is fine. On the server where I want to copy this custom application and run all assemblies I am referencing are in folder something like: D:\

What are major differences between C# and Java?

佐手、 提交于 2019-11-26 06:50:01
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. I just want to clarify one thing. This is not a question on which one is better, that part I leave to someone else to discuss. I don\'t care about it. I\'ve been asked this question on my job interview and I thought it might be useful to learn a bit more. These are the ones I could come up with: Java is \"platform

.NET 4.0 and the dreaded OnUserPreferenceChanged Hang

回眸只為那壹抹淺笑 提交于 2019-11-26 06:44:18
问题 I have been plagued with the dreaded OnUserPreferenceChanged Hang that\'s refered to quite nicely by Ivan Krivyakov, here: http://ikriv.com/en/prog/info/dotnet/MysteriousHang.html#BeginInvokeDance I posted a question a while back, when I originally encountered the problem: Yet another C# Deadlock Debugging Question I thought I had solved it by removing a Control that was constructed off the UI thread, but after a little while it reappeared (probably never left...). We\'ve been using .NET 3.5,

What is a “rooted reference”?

孤者浪人 提交于 2019-11-26 06:40:19
问题 Quote from ( Safe in C# not in C++, simple return of pointer / reference, answer 3) by Eric lippert. Also, note that it is not any reference to the Person object that keeps it alive. The reference has to be rooted. You could have two Person objects that reference each other but are otherwise unreachable; the fact that each has a reference does not keep them alive; one of the references has to be rooted. I dont understand, can someone explain what a rooted reference is? 回答1: It means a GC root